|
29 | 29 | * @author Rod Johnson
|
30 | 30 | * @author Juergen Hoeller
|
31 | 31 | * @author Rick Evans
|
| 32 | + * @author Sam Brannen |
32 | 33 | */
|
33 | 34 | class StringUtilsTests {
|
34 | 35 |
|
@@ -272,29 +273,29 @@ void deleteAny() {
|
272 | 273 | String inString = "Able was I ere I saw Elba";
|
273 | 274 |
|
274 | 275 | 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"); |
276 | 277 |
|
277 | 278 | 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"); |
279 | 280 |
|
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 | + } |
282 | 284 |
|
| 285 | + @Test |
| 286 | + void deleteAnyWhitespace() { |
283 | 287 | 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 | + |
287 | 292 | 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); |
295 | 297 | }
|
296 | 298 |
|
297 |
| - |
298 | 299 | @Test
|
299 | 300 | void quote() {
|
300 | 301 | assertThat(StringUtils.quote("myString")).isEqualTo("'myString'");
|
|
0 commit comments