|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -467,6 +467,18 @@ void sortStringArray() {
|
467 | 467 | assertThat(input[1]).isEqualTo("myString2");
|
468 | 468 | }
|
469 | 469 |
|
| 470 | + @Test |
| 471 | + void trimArrayElements() { |
| 472 | + assertThat(StringUtils.trimArrayElements(null)).isNull(); |
| 473 | + assertThat(StringUtils.trimArrayElements(new String[] {})).isEmpty(); |
| 474 | + assertThat(StringUtils.trimArrayElements(new String[] { "", " ", " ", " " })).containsExactly("", "", "", ""); |
| 475 | + assertThat(StringUtils.trimArrayElements(new String[] { "\n", "\t ", "\n\t" })).containsExactly("", "", ""); |
| 476 | + assertThat(StringUtils.trimArrayElements(new String[] { "a", "b", "c" })).containsExactly("a", "b", "c"); |
| 477 | + assertThat(StringUtils.trimArrayElements(new String[] { " a ", " b b ", " cc " })).containsExactly("a", "b b", "cc"); |
| 478 | + assertThat(StringUtils.trimArrayElements(new String[] { " a ", "b", " c " })).containsExactly("a", "b", "c"); |
| 479 | + assertThat(StringUtils.trimArrayElements(new String[] { null, " a ", null })).containsExactly(null, "a", null); |
| 480 | + } |
| 481 | + |
470 | 482 | @Test
|
471 | 483 | void removeDuplicateStrings() {
|
472 | 484 | String[] input = new String[] {"myString2", "myString1", "myString2"};
|
@@ -558,6 +570,18 @@ void delimitedListToStringArrayWithNullDelimiter() {
|
558 | 570 | assertThat(sa[0]).isEqualTo("a,b");
|
559 | 571 | }
|
560 | 572 |
|
| 573 | + @Test |
| 574 | + void delimitedListToStringArrayWithCharacterToDelete() { |
| 575 | + String[] sa = StringUtils.delimitedListToStringArray("a,b,c", ",", "a"); |
| 576 | + assertThat(sa).containsExactly("", "b", "c"); |
| 577 | + } |
| 578 | + |
| 579 | + @Test |
| 580 | + void delimitedListToStringArrayWithCharacterToDeleteEqualsToDelimiter() { |
| 581 | + String[] sa = StringUtils.delimitedListToStringArray("a,b,c", ",", ","); |
| 582 | + assertThat(sa).containsExactly("a", "b", "c"); |
| 583 | + } |
| 584 | + |
561 | 585 | @Test
|
562 | 586 | void commaDelimitedListToStringArrayMatchWords() {
|
563 | 587 | // Could read these from files
|
|
0 commit comments