aboutsummaryrefslogtreecommitdiff
path: root/guava-tests/test/com/google/common/base/CharMatcherTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'guava-tests/test/com/google/common/base/CharMatcherTest.java')
-rw-r--r--guava-tests/test/com/google/common/base/CharMatcherTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/guava-tests/test/com/google/common/base/CharMatcherTest.java b/guava-tests/test/com/google/common/base/CharMatcherTest.java
index 49bdbbaff..d78327ef0 100644
--- a/guava-tests/test/com/google/common/base/CharMatcherTest.java
+++ b/guava-tests/test/com/google/common/base/CharMatcherTest.java
@@ -27,6 +27,7 @@ import static com.google.common.base.CharMatcher.whitespace;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.Sets;
import com.google.common.testing.NullPointerTester;
import java.util.Arrays;
@@ -43,8 +44,10 @@ import junit.framework.TestCase;
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
+@ElementTypesAreNonnullByDefault
public class CharMatcherTest extends TestCase {
+ @J2ktIncompatible
@GwtIncompatible // NullPointerTester
public void testStaticNullPointers() throws Exception {
NullPointerTester tester = new NullPointerTester();
@@ -90,6 +93,7 @@ public class CharMatcherTest extends TestCase {
// The next tests require ICU4J and have, at least for now, been sliced out
// of the open-source view of the tests.
+ @J2ktIncompatible
@GwtIncompatible // Character.isISOControl
public void testJavaIsoControl() {
for (int c = 0; c <= Character.MAX_VALUE; c++) {
@@ -108,6 +112,7 @@ public class CharMatcherTest extends TestCase {
// method, but by overall "scenario". Also, the variety of actual tests we
// do borders on absurd overkill. Better safe than sorry, though?
+ @J2ktIncompatible
@GwtIncompatible // java.util.BitSet
public void testSetBits() {
doTestSetBits(CharMatcher.any());
@@ -128,6 +133,7 @@ public class CharMatcherTest extends TestCase {
doTestSetBits(inRange('A', 'Z').and(inRange('F', 'K').negate()));
}
+ @J2ktIncompatible
@GwtIncompatible // java.util.BitSet
private void doTestSetBits(CharMatcher matcher) {
BitSet bitset = new BitSet();
@@ -151,6 +157,7 @@ public class CharMatcherTest extends TestCase {
doTestEmpty(forPredicate(Predicates.equalTo('c')));
}
+ @J2ktIncompatible
@GwtIncompatible // NullPointerTester
public void testNull() throws Exception {
doTestNull(CharMatcher.any());
@@ -196,6 +203,7 @@ public class CharMatcherTest extends TestCase {
assertEquals(0, matcher.countIn(""));
}
+ @J2ktIncompatible
@GwtIncompatible // NullPointerTester
private static void doTestNull(CharMatcher matcher) throws Exception {
NullPointerTester tester = new NullPointerTester();
@@ -644,6 +652,14 @@ public class CharMatcherTest extends TestCase {
assertEquals("12 &gt; 5", is('>').replaceFrom("12 > 5", "&gt;"));
}
+ 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
@@ -664,11 +680,13 @@ public class CharMatcherTest extends TestCase {
assertSame(CharMatcher.any(), CharMatcher.any().precomputed());
}
+ @J2ktIncompatible
@GwtIncompatible // java.util.BitSet
private static BitSet bitSet(String chars) {
return bitSet(chars.toCharArray());
}
+ @J2ktIncompatible
@GwtIncompatible // java.util.BitSet
private static BitSet bitSet(char[] chars) {
BitSet tmp = new BitSet();
@@ -678,6 +696,7 @@ public class CharMatcherTest extends TestCase {
return tmp;
}
+ @J2ktIncompatible
@GwtIncompatible // java.util.Random, java.util.BitSet
public void testSmallCharMatcher() {
CharMatcher len1 = SmallCharMatcher.from(bitSet("#"), "#");