CodePoints implements Serializable { public boolean containsAll(String s) { return this.firstExcludedCodePoint(s) == NOT_FOUND; } CodePoints(Integer... codePoints);  CodePoints(String... strings);  CodePoints(Collection<Integer> codePoints);  CodePoints(CodePoints codePoints); boolean containsAll(String s); int firstExcludedCodePoint(String s); Set<Integer> allExcludedCodePoints(String s); CodePoints union(CodePoints codePoints); CodePoints subtract(CodePoints codePoints); CodePoints intersect(CodePoints codePoints); @SuppressWarnings("unchecked") static T of(Class<T> clazz); static boolean containsAllInAnyCodePoints(String s,
            final CodePoints... codePointsList); @Override boolean equals(Object o); @Override int hashCode(); static final int NOT_FOUND; }
@Test public void testContainsAll() { CodePoints codePoints = new CodePoints("あ", "い", "う"); assertThat(codePoints.containsAll("あ"), is(true)); assertThat(codePoints.containsAll("い"), is(true)); assertThat(codePoints.containsAll("う"), is(true)); assertThat(codePoints.containsAll("あい"), is(true)); assertThat(codePoints.containsAll("いう"), is(true)); assertThat(codePoints.containsAll("うあ"), is(true)); assertThat(codePoints.containsAll("あいう"), is(true)); assertThat(codePoints.containsAll("あいうえ"), is(false)); }
@Test public void testIsAllowedString_null() { String testStr = null; Set<Integer> allowedCodePointSet = new HashSet<Integer>(); boolean result = new CodePoints(allowedCodePointSet).containsAll( testStr); assertThat(result, is(true)); }
@Test public void testIsAllowedString_empty() { String testStr = ""; Set<Integer> allowedCodePointSet = new HashSet<Integer>(); boolean result = new CodePoints(allowedCodePointSet).containsAll( testStr); assertThat(result, is(true)); }
@Test public void testIsAllowedString_allAllowedCodePoints() { String testStr = SURROGATE_PAIR_CHAR_2000B + "あいうあ" + SURROGATE_PAIR_CHAR_2000B; Set<Integer> allowedCodePointSet = new HashSet<Integer>(); allowedCodePointSet.add("あ".codePointAt(0)); allowedCodePointSet.add("い".codePointAt(0)); allowedCodePointSet.add("う".codePointAt(0)); allowedCodePointSet.add("え".codePointAt(0)); allowedCodePointSet.add("お".codePointAt(0)); allowedCodePointSet.add(0x2000B); boolean result = new CodePoints(allowedCodePointSet).containsAll( testStr); assertThat(result, is(true)); }
@Test public void testIsAllowedString_includingNotAllowedCodePoint() { String testStr = SURROGATE_PAIR_CHAR_2000B + "あいうか" + SURROGATE_PAIR_CHAR_2000B; Set<Integer> allowedCodePointSet = new HashSet<Integer>(); allowedCodePointSet.add("あ".codePointAt(0)); allowedCodePointSet.add("い".codePointAt(0)); allowedCodePointSet.add("う".codePointAt(0)); allowedCodePointSet.add("え".codePointAt(0)); allowedCodePointSet.add("お".codePointAt(0)); allowedCodePointSet.add(0x2000B); boolean result = new CodePoints(allowedCodePointSet).containsAll( testStr); assertThat(result, is(false)); }
@Test public void testIsAllowedString_includingNotAllowedSurrogatePair() { String testStr = SURROGATE_PAIR_CHAR_2000B + "あいうあ" + SURROGATE_PARE_CHAR_20B9F; Set<Integer> allowedCodePointSet = new HashSet<Integer>(); allowedCodePointSet.add("あ".codePointAt(0)); allowedCodePointSet.add("い".codePointAt(0)); allowedCodePointSet.add("う".codePointAt(0)); allowedCodePointSet.add("え".codePointAt(0)); allowedCodePointSet.add("お".codePointAt(0)); allowedCodePointSet.add(0x2000B); boolean result = new CodePoints(allowedCodePointSet).containsAll( testStr); assertThat(result, is(false)); }