Skip to content

Commit e9ccc46

Browse files
committed
add tests for retainFrom() and countIn()
1 parent 8356e14 commit e9ccc46

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/test/java/org/sooo/base/CharMatcherTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,30 @@ public void retainOnlyDigitsAndLowerCases() {
6969
// then
7070
assertThat(lowerAndDigit, is("2oreansnd3mericans"));
7171
}
72+
73+
@Test
74+
public void removeNonASCIIAndTabCharacters() {
75+
// given
76+
String input = "This string has Korean characters(한국어) and a tab\tcharacter.";
77+
78+
// when
79+
String filtered = CharMatcher.ASCII.and(CharMatcher.isNot('\t'))
80+
.retainFrom(input);
81+
82+
// then
83+
assertThat(filtered,
84+
is("This string has Korean characters() and a tabcharacter."));
85+
}
86+
87+
@Test
88+
public void countTabCharacter() {
89+
// given
90+
String input = "\ta\tb\tc\td";
91+
92+
// when
93+
int count = CharMatcher.is('\t').countIn(input);
94+
95+
// then
96+
assertThat(count, is(4));
97+
}
7298
}

0 commit comments

Comments
 (0)