Skip to content

Commit

Permalink
Add unit test for untested CharMatcher.retainFrom() method.
Browse files Browse the repository at this point in the history
Fixes #6500
Fixes #6069

RELNOTES=n/a
PiperOrigin-RevId: 532889411
  • Loading branch information
konstantin-goldman authored and Google Java Core Libraries committed May 17, 2023
1 parent b482864 commit 3a8d7e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,14 @@ public void testReplaceFrom() {
assertEquals("12 > 5", is('>').replaceFrom("12 > 5", ">"));
}

public void testRetainFrom() {
assertEquals("aaa", is('a').retainFrom("bazaar"));
assertEquals("z", is('z').retainFrom("bazaar"));
assertEquals("!", is('!').retainFrom("!@#$%^&*()-="));
assertEquals("", is('x').retainFrom("bazaar"));
assertEquals("", is('a').retainFrom(""));
}

public void testPrecomputedOptimizations() {
// These are testing behavior that's never promised by the API.
// Some matchers are so efficient that it is a waste of effort to
Expand Down
8 changes: 8 additions & 0 deletions guava-tests/test/com/google/common/base/CharMatcherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,14 @@ public void testReplaceFrom() {
assertEquals("12 > 5", is('>').replaceFrom("12 > 5", ">"));
}

public void testRetainFrom() {
assertEquals("aaa", is('a').retainFrom("bazaar"));
assertEquals("z", is('z').retainFrom("bazaar"));
assertEquals("!", is('!').retainFrom("!@#$%^&*()-="));
assertEquals("", is('x').retainFrom("bazaar"));
assertEquals("", is('a').retainFrom(""));
}

public void testPrecomputedOptimizations() {
// These are testing behavior that's never promised by the API.
// Some matchers are so efficient that it is a waste of effort to
Expand Down

0 comments on commit 3a8d7e4

Please sign in to comment.