本文整理了Java中org.assertj.core.api.AbstractStringAssert.is()
方法的一些代码示例,展示了AbstractStringAssert.is()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractStringAssert.is()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractStringAssert
类名称:AbstractStringAssert
方法名:is
[英]Verifies that the actual value is in [start, end] range (start included, end included) according to String#compareTo(String).
Note that it is possible to change the comparison strategy with AbstractAssert#usingComparator(Comparator).
Examples:
// assertions succeed
assertThat("ab").isBetween("aa", "ac")
.isBetween("ab", "ac")
.isBetween("aa", "ab")
.isBetween("ab", "ab")
.isBetween("a", "c")
.usingComparator(CASE_INSENSITIVE)
.isBetween("AA", "AC");
// assertions fail
assertThat("ab").isBetween("ac", "bc");
assertThat("ab").isBetween("abc", "ac");
[中]根据字符串#compareTo(字符串),验证实际值是否在[start,end]范围内(包括开始,包括结束)。
请注意,可以使用AbstractAssert#usingComparator(Comparator)更改比较策略。
示例:
// assertions succeed
assertThat("ab").isBetween("aa", "ac")
.isBetween("ab", "ac")
.isBetween("aa", "ab")
.isBetween("ab", "ab")
.isBetween("a", "c")
.usingComparator(CASE_INSENSITIVE)
.isBetween("AA", "AC");
// assertions fail
assertThat("ab").isBetween("ac", "bc");
assertThat("ab").isBetween("abc", "ac");
代码示例来源:origin: spring-io/initializr
@Test
void matchUnboundedRangeEqual() {
assertThat("1.2.0.RELEASE").is(match("1.2.0.RELEASE"));
}
代码示例来源:origin: spring-io/initializr
@Test
void matchInclusiveHigherRange() {
assertThat("1.2.0.RC5").is(match("[1.2.0.RC1,1.2.0.RC5]"));
}
代码示例来源:origin: spring-io/initializr
@Test
void rangeWithSpaces() {
assertThat("1.2.0.RC3").is(match("[ 1.2.0.RC1 , 1.2.0.RC5]"));
}
代码示例来源:origin: spring-io/initializr
@Test
void matchSimpleRange() {
assertThat("1.2.0.RC3").is(match("[1.2.0.RC1,1.2.0.RC5]"));
}
代码示例来源:origin: spring-io/initializr
@Test
void matchInclusiveLowerRange() {
assertThat("1.2.0.RC1").is(match("[1.2.0.RC1,1.2.0.RC5]"));
}
代码示例来源:origin: spring-io/initializr
@Test
void matchUnboundedRangeAfter() {
assertThat("2.2.0.RELEASE").is(match("1.2.0.RELEASE"));
}
代码示例来源:origin: spring-io/initializr
@Test
void matchLatestVersion() {
assertThat("1.2.8.RELEASE").is(match("[1.2.0.RELEASE,1.2.x.BUILD-SNAPSHOT]",
new VersionParser(Collections
.singletonList(Version.parse("1.2.9.BUILD-SNAPSHOT")))));
}
代码示例来源:origin: spring-io/initializr
@Test
void matchAsOfCurrentVersion() {
assertThat("1.3.5.RELEASE").is(match("[1.3.x.RELEASE,1.3.x.BUILD-SNAPSHOT]",
new VersionParser(Arrays.asList(Version.parse("1.3.4.RELEASE"),
Version.parse("1.3.6.BUILD-SNAPSHOT")))));
}
代码示例来源:origin: io.syndesis.common/common-util
/**
* Generate keys in a tight loop and verify that we don't generate a dup key
* since keys have a timestamp component to them.
*/
@Test
public void testCreateKey() {
// Check to make sure we don't generate dup keys and that they are ordered properly
String last = KeyGenerator.createKey();
for (int i = 0; i < 1000000; i++) {
final String lastKey = last;
final String key = KeyGenerator.createKey();
Assertions.assertThat(key).is(new Condition<>((other) -> lastKey.compareTo(other) < 0, "greater than " + lastKey));
last = key;
}
}
内容来源于网络,如有侵权,请联系作者删除!