Skip to content

Commit 3dadcae

Browse files
committed
Polishing
1 parent 87fa2c3 commit 3dadcae

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

spring-core/src/test/java/org/springframework/util/StringUtilsTests.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* @author Rod Johnson
3030
* @author Juergen Hoeller
3131
* @author Rick Evans
32+
* @author Sam Brannen
3233
*/
3334
class StringUtilsTests {
3435

@@ -272,29 +273,29 @@ void deleteAny() {
272273
String inString = "Able was I ere I saw Elba";
273274

274275
String res = StringUtils.deleteAny(inString, "I");
275-
assertThat(res.equals("Able was ere saw Elba")).as("Result has no Is [" + res + "]").isTrue();
276+
assertThat(res).as("Result has no 'I'").isEqualTo("Able was ere saw Elba");
276277

277278
res = StringUtils.deleteAny(inString, "AeEba!");
278-
assertThat(res.equals("l ws I r I sw l")).as("Result has no Is [" + res + "]").isTrue();
279+
assertThat(res).as("Result has no 'AeEba!'").isEqualTo("l ws I r I sw l");
279280

280-
String mismatch = StringUtils.deleteAny(inString, "#@$#$^");
281-
assertThat(mismatch.equals(inString)).as("Result is unchanged").isTrue();
281+
res = StringUtils.deleteAny(inString, "#@$#$^");
282+
assertThat(res).as("Result is unchanged").isEqualTo(inString);
283+
}
282284

285+
@Test
286+
void deleteAnyWhitespace() {
283287
String whitespace = "This is\n\n\n \t a messagy string with whitespace\n";
284-
assertThat(whitespace.contains("\n")).as("Has CR").isTrue();
285-
assertThat(whitespace.contains("\t")).as("Has tab").isTrue();
286-
assertThat(whitespace.contains(" ")).as("Has sp").isTrue();
288+
assertThat(whitespace).as("Has CR").contains("\n");
289+
assertThat(whitespace).as("Has tab").contains("\t");
290+
assertThat(whitespace).as("Has space").contains(" ");
291+
287292
String cleaned = StringUtils.deleteAny(whitespace, "\n\t ");
288-
boolean condition2 = !cleaned.contains("\n");
289-
assertThat(condition2).as("Has no CR").isTrue();
290-
boolean condition1 = !cleaned.contains("\t");
291-
assertThat(condition1).as("Has no tab").isTrue();
292-
boolean condition = !cleaned.contains(" ");
293-
assertThat(condition).as("Has no sp").isTrue();
294-
assertThat(cleaned.length() > 10).as("Still has chars").isTrue();
293+
assertThat(cleaned).as("Has no CR").doesNotContain("\n");
294+
assertThat(cleaned).as("Has no tab").doesNotContain("\t");
295+
assertThat(cleaned).as("Has no space").doesNotContain(" ");
296+
assertThat(cleaned.length()).as("Still has chars").isGreaterThan(10);
295297
}
296298

297-
298299
@Test
299300
void quote() {
300301
assertThat(StringUtils.quote("myString")).isEqualTo("'myString'");

0 commit comments

Comments
 (0)