Applying patch from Vincent Ricard in LANG-514. CharRange constructors removed and replaced with readable static builder methods
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@829282 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba0205c202
commit
51a130b544
|
@ -48,39 +48,6 @@ public final class CharRange implements Serializable {
|
||||||
/** Cached toString. */
|
/** Cached toString. */
|
||||||
private transient String iToString;
|
private transient String iToString;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>Constructs a <code>CharRange</code> over a single character.</p>
|
|
||||||
*
|
|
||||||
* @param ch only character in this range
|
|
||||||
*/
|
|
||||||
public CharRange(char ch) {
|
|
||||||
this(ch, ch, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Constructs a <code>CharRange</code> over a single character,
|
|
||||||
* optionally negating the range.</p>
|
|
||||||
*
|
|
||||||
* <p>A negated range includes everything except the specified char.</p>
|
|
||||||
*
|
|
||||||
* @param ch only character in this range
|
|
||||||
* @param negated true to express everything except the range
|
|
||||||
*/
|
|
||||||
public CharRange(char ch, boolean negated) {
|
|
||||||
this(ch, ch, negated);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Constructs a <code>CharRange</code> over a set of characters.</p>
|
|
||||||
*
|
|
||||||
* @param start first character, inclusive, in this range
|
|
||||||
* @param end last character, inclusive, in this range
|
|
||||||
*/
|
|
||||||
public CharRange(char start, char end) {
|
|
||||||
this(start, end, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructs a <code>CharRange</code> over a set of characters,
|
* <p>Constructs a <code>CharRange</code> over a set of characters,
|
||||||
* optionally negating the range.</p>
|
* optionally negating the range.</p>
|
||||||
|
@ -95,7 +62,7 @@ public final class CharRange implements Serializable {
|
||||||
* @param end last character, inclusive, in this range
|
* @param end last character, inclusive, in this range
|
||||||
* @param negated true to express everything except the range
|
* @param negated true to express everything except the range
|
||||||
*/
|
*/
|
||||||
public CharRange(char start, char end, boolean negated) {
|
private CharRange(char start, char end, boolean negated) {
|
||||||
super();
|
super();
|
||||||
if (start > end) {
|
if (start > end) {
|
||||||
char temp = start;
|
char temp = start;
|
||||||
|
@ -108,6 +75,48 @@ public final class CharRange implements Serializable {
|
||||||
this.negated = negated;
|
this.negated = negated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructs a <code>CharRange</code> over a single character.</p>
|
||||||
|
*
|
||||||
|
* @param ch only character in this range
|
||||||
|
* @see CharRange#CharRange(char, boolean)
|
||||||
|
*/
|
||||||
|
public static CharRange is(char ch) {
|
||||||
|
return new CharRange(ch, ch, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructs a negated <code>CharRange</code> over a single character.</p>
|
||||||
|
*
|
||||||
|
* @param ch only character in this range
|
||||||
|
* @see CharRange#CharRange(char, boolean)
|
||||||
|
*/
|
||||||
|
public static CharRange isNot(char ch) {
|
||||||
|
return new CharRange(ch, ch, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructs a <code>CharRange</code> over a set of characters.</p>
|
||||||
|
*
|
||||||
|
* @param start first character, inclusive, in this range
|
||||||
|
* @param end last character, inclusive, in this range
|
||||||
|
* @see CharRange#CharRange(char, char, boolean)
|
||||||
|
*/
|
||||||
|
public static CharRange isIn(char start, char end) {
|
||||||
|
return new CharRange(start, end, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Constructs a negated <code>CharRange</code> over a set of characters.</p>
|
||||||
|
*
|
||||||
|
* @param start first character, inclusive, in this range
|
||||||
|
* @param end last character, inclusive, in this range
|
||||||
|
* @see CharRange#CharRange(char, char, boolean)
|
||||||
|
*/
|
||||||
|
public static CharRange isNotIn(char start, char end) {
|
||||||
|
return new CharRange(start, end, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -204,19 +204,19 @@ public class CharSet implements Serializable {
|
||||||
int remainder = (len - pos);
|
int remainder = (len - pos);
|
||||||
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') {
|
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') {
|
||||||
// negated range
|
// negated range
|
||||||
set.add(new CharRange(str.charAt(pos + 1), str.charAt(pos + 3), true));
|
set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3)));
|
||||||
pos += 4;
|
pos += 4;
|
||||||
} else if (remainder >= 3 && str.charAt(pos + 1) == '-') {
|
} else if (remainder >= 3 && str.charAt(pos + 1) == '-') {
|
||||||
// range
|
// range
|
||||||
set.add(new CharRange(str.charAt(pos), str.charAt(pos + 2)));
|
set.add(CharRange.isIn(str.charAt(pos), str.charAt(pos + 2)));
|
||||||
pos += 3;
|
pos += 3;
|
||||||
} else if (remainder >= 2 && str.charAt(pos) == '^') {
|
} else if (remainder >= 2 && str.charAt(pos) == '^') {
|
||||||
// negated char
|
// negated char
|
||||||
set.add(new CharRange(str.charAt(pos + 1), true));
|
set.add(CharRange.isNot(str.charAt(pos + 1)));
|
||||||
pos += 2;
|
pos += 2;
|
||||||
} else {
|
} else {
|
||||||
// char
|
// char
|
||||||
set.add(new CharRange(str.charAt(pos)));
|
set.add(CharRange.is(str.charAt(pos)));
|
||||||
pos += 1;
|
pos += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,96 +64,64 @@ public class CharRangeTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public void testConstructorAccessors_Char() {
|
public void testConstructorAccessors_is() {
|
||||||
CharRange rangea = new CharRange('a');
|
CharRange rangea = CharRange.is('a');
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('a', rangea.getEnd());
|
assertEquals('a', rangea.getEnd());
|
||||||
assertEquals(false, rangea.isNegated());
|
assertEquals(false, rangea.isNegated());
|
||||||
assertEquals("a", rangea.toString());
|
assertEquals("a", rangea.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorAccessors_CharBoolean_Normal() {
|
public void testConstructorAccessors_isNot() {
|
||||||
CharRange rangea = new CharRange('a');
|
CharRange rangea = CharRange.isNot('a');
|
||||||
assertEquals('a', rangea.getStart());
|
|
||||||
assertEquals('a', rangea.getEnd());
|
|
||||||
assertEquals(false, rangea.isNegated());
|
|
||||||
assertEquals("a", rangea.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testConstructorAccessors_CharBoolean_Negated() {
|
|
||||||
CharRange rangea = new CharRange('a', true);
|
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('a', rangea.getEnd());
|
assertEquals('a', rangea.getEnd());
|
||||||
assertEquals(true, rangea.isNegated());
|
assertEquals(true, rangea.isNegated());
|
||||||
assertEquals("^a", rangea.toString());
|
assertEquals("^a", rangea.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorAccessors_CharChar_Same() {
|
public void testConstructorAccessors_isIn_Same() {
|
||||||
CharRange rangea = new CharRange('a', 'a');
|
CharRange rangea = CharRange.isIn('a', 'a');
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('a', rangea.getEnd());
|
assertEquals('a', rangea.getEnd());
|
||||||
assertEquals(false, rangea.isNegated());
|
assertEquals(false, rangea.isNegated());
|
||||||
assertEquals("a", rangea.toString());
|
assertEquals("a", rangea.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorAccessors_CharChar_Normal() {
|
public void testConstructorAccessors_isIn_Normal() {
|
||||||
CharRange rangea = new CharRange('a', 'e');
|
CharRange rangea = CharRange.isIn('a', 'e');
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('e', rangea.getEnd());
|
assertEquals('e', rangea.getEnd());
|
||||||
assertEquals(false, rangea.isNegated());
|
assertEquals(false, rangea.isNegated());
|
||||||
assertEquals("a-e", rangea.toString());
|
assertEquals("a-e", rangea.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorAccessors_CharChar_Reversed() {
|
public void testConstructorAccessors_isIn_Reversed() {
|
||||||
CharRange rangea = new CharRange('e', 'a');
|
CharRange rangea = CharRange.isIn('e', 'a');
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('e', rangea.getEnd());
|
assertEquals('e', rangea.getEnd());
|
||||||
assertEquals(false, rangea.isNegated());
|
assertEquals(false, rangea.isNegated());
|
||||||
assertEquals("a-e", rangea.toString());
|
assertEquals("a-e", rangea.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorAccessors_CharCharBoolean_Same() {
|
public void testConstructorAccessors_isNotIn_Same() {
|
||||||
CharRange rangea = new CharRange('a', 'a', false);
|
CharRange rangea = CharRange.isNotIn('a', 'a');
|
||||||
assertEquals('a', rangea.getStart());
|
|
||||||
assertEquals('a', rangea.getEnd());
|
|
||||||
assertEquals(false, rangea.isNegated());
|
|
||||||
assertEquals("a", rangea.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testConstructorAccessors_CharCharBoolean_Normal() {
|
|
||||||
CharRange rangea = new CharRange('a', 'e', false);
|
|
||||||
assertEquals('a', rangea.getStart());
|
|
||||||
assertEquals('e', rangea.getEnd());
|
|
||||||
assertEquals(false, rangea.isNegated());
|
|
||||||
assertEquals("a-e", rangea.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testConstructorAccessors_CharCharBoolean_Reversed() {
|
|
||||||
CharRange rangea = new CharRange('e', 'a', false);
|
|
||||||
assertEquals('a', rangea.getStart());
|
|
||||||
assertEquals('e', rangea.getEnd());
|
|
||||||
assertEquals(false, rangea.isNegated());
|
|
||||||
assertEquals("a-e", rangea.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testConstructorAccessors_CharCharBoolean_SameNegated() {
|
|
||||||
CharRange rangea = new CharRange('a', 'a', true);
|
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('a', rangea.getEnd());
|
assertEquals('a', rangea.getEnd());
|
||||||
assertEquals(true, rangea.isNegated());
|
assertEquals(true, rangea.isNegated());
|
||||||
assertEquals("^a", rangea.toString());
|
assertEquals("^a", rangea.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorAccessors_CharCharBoolean_NormalNegated() {
|
public void testConstructorAccessors_isNotIn_Normal() {
|
||||||
CharRange rangea = new CharRange('a', 'e', true);
|
CharRange rangea = CharRange.isNotIn('a', 'e');
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('e', rangea.getEnd());
|
assertEquals('e', rangea.getEnd());
|
||||||
assertEquals(true, rangea.isNegated());
|
assertEquals(true, rangea.isNegated());
|
||||||
assertEquals("^a-e", rangea.toString());
|
assertEquals("^a-e", rangea.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructorAccessors_CharCharBoolean_ReversedNegated() {
|
public void testConstructorAccessors_isNotIn_Reversed() {
|
||||||
CharRange rangea = new CharRange('e', 'a', true);
|
CharRange rangea = CharRange.isNotIn('e', 'a');
|
||||||
assertEquals('a', rangea.getStart());
|
assertEquals('a', rangea.getStart());
|
||||||
assertEquals('e', rangea.getEnd());
|
assertEquals('e', rangea.getEnd());
|
||||||
assertEquals(true, rangea.isNegated());
|
assertEquals(true, rangea.isNegated());
|
||||||
|
@ -162,18 +130,18 @@ public class CharRangeTest extends TestCase {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public void testEquals_Object() {
|
public void testEquals_Object() {
|
||||||
CharRange rangea = new CharRange('a');
|
CharRange rangea = CharRange.is('a');
|
||||||
CharRange rangeae = new CharRange('a', 'e');
|
CharRange rangeae = CharRange.isIn('a', 'e');
|
||||||
CharRange rangenotbf = new CharRange('b', 'f', false);
|
CharRange rangenotbf = CharRange.isIn('b', 'f');
|
||||||
|
|
||||||
assertEquals(false, rangea.equals(null));
|
assertEquals(false, rangea.equals(null));
|
||||||
|
|
||||||
assertEquals(true, rangea.equals(rangea));
|
assertEquals(true, rangea.equals(rangea));
|
||||||
assertEquals(true, rangea.equals(new CharRange('a')));
|
assertEquals(true, rangea.equals(CharRange.is('a')));
|
||||||
assertEquals(true, rangeae.equals(rangeae));
|
assertEquals(true, rangeae.equals(rangeae));
|
||||||
assertEquals(true, rangeae.equals(new CharRange('a', 'e')));
|
assertEquals(true, rangeae.equals(CharRange.isIn('a', 'e')));
|
||||||
assertEquals(true, rangenotbf.equals(rangenotbf));
|
assertEquals(true, rangenotbf.equals(rangenotbf));
|
||||||
assertEquals(true, rangenotbf.equals(new CharRange('b', 'f', false)));
|
assertEquals(true, rangenotbf.equals(CharRange.isIn('b', 'f')));
|
||||||
|
|
||||||
assertEquals(false, rangea.equals(rangeae));
|
assertEquals(false, rangea.equals(rangeae));
|
||||||
assertEquals(false, rangea.equals(rangenotbf));
|
assertEquals(false, rangea.equals(rangenotbf));
|
||||||
|
@ -184,16 +152,16 @@ public class CharRangeTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHashCode() {
|
public void testHashCode() {
|
||||||
CharRange rangea = new CharRange('a');
|
CharRange rangea = CharRange.is('a');
|
||||||
CharRange rangeae = new CharRange('a', 'e');
|
CharRange rangeae = CharRange.isIn('a', 'e');
|
||||||
CharRange rangenotbf = new CharRange('b', 'f', false);
|
CharRange rangenotbf = CharRange.isIn('b', 'f');
|
||||||
|
|
||||||
assertEquals(true, rangea.hashCode() == rangea.hashCode());
|
assertEquals(true, rangea.hashCode() == rangea.hashCode());
|
||||||
assertEquals(true, rangea.hashCode() == new CharRange('a').hashCode());
|
assertEquals(true, rangea.hashCode() == CharRange.is('a').hashCode());
|
||||||
assertEquals(true, rangeae.hashCode() == rangeae.hashCode());
|
assertEquals(true, rangeae.hashCode() == rangeae.hashCode());
|
||||||
assertEquals(true, rangeae.hashCode() == new CharRange('a', 'e').hashCode());
|
assertEquals(true, rangeae.hashCode() == CharRange.isIn('a', 'e').hashCode());
|
||||||
assertEquals(true, rangenotbf.hashCode() == rangenotbf.hashCode());
|
assertEquals(true, rangenotbf.hashCode() == rangenotbf.hashCode());
|
||||||
assertEquals(true, rangenotbf.hashCode() == new CharRange('b', 'f', false).hashCode());
|
assertEquals(true, rangenotbf.hashCode() == CharRange.isIn('b', 'f').hashCode());
|
||||||
|
|
||||||
assertEquals(false, rangea.hashCode() == rangeae.hashCode());
|
assertEquals(false, rangea.hashCode() == rangeae.hashCode());
|
||||||
assertEquals(false, rangea.hashCode() == rangenotbf.hashCode());
|
assertEquals(false, rangea.hashCode() == rangenotbf.hashCode());
|
||||||
|
@ -205,31 +173,25 @@ public class CharRangeTest extends TestCase {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public void testContains_Char() {
|
public void testContains_Char() {
|
||||||
CharRange range = new CharRange('c');
|
CharRange range = CharRange.is('c');
|
||||||
assertEquals(false, range.contains('b'));
|
assertEquals(false, range.contains('b'));
|
||||||
assertEquals(true, range.contains('c'));
|
assertEquals(true, range.contains('c'));
|
||||||
assertEquals(false, range.contains('d'));
|
assertEquals(false, range.contains('d'));
|
||||||
assertEquals(false, range.contains('e'));
|
assertEquals(false, range.contains('e'));
|
||||||
|
|
||||||
range = new CharRange('c', 'd');
|
range = CharRange.isIn('c', 'd');
|
||||||
assertEquals(false, range.contains('b'));
|
assertEquals(false, range.contains('b'));
|
||||||
assertEquals(true, range.contains('c'));
|
assertEquals(true, range.contains('c'));
|
||||||
assertEquals(true, range.contains('d'));
|
assertEquals(true, range.contains('d'));
|
||||||
assertEquals(false, range.contains('e'));
|
assertEquals(false, range.contains('e'));
|
||||||
|
|
||||||
range = new CharRange('d', 'c');
|
range = CharRange.isIn('d', 'c');
|
||||||
assertEquals(false, range.contains('b'));
|
assertEquals(false, range.contains('b'));
|
||||||
assertEquals(true, range.contains('c'));
|
assertEquals(true, range.contains('c'));
|
||||||
assertEquals(true, range.contains('d'));
|
assertEquals(true, range.contains('d'));
|
||||||
assertEquals(false, range.contains('e'));
|
assertEquals(false, range.contains('e'));
|
||||||
|
|
||||||
range = new CharRange('c', 'd', false);
|
range = CharRange.isNotIn('c', 'd');
|
||||||
assertEquals(false, range.contains('b'));
|
|
||||||
assertEquals(true, range.contains('c'));
|
|
||||||
assertEquals(true, range.contains('d'));
|
|
||||||
assertEquals(false, range.contains('e'));
|
|
||||||
|
|
||||||
range = new CharRange('c', 'd', true);
|
|
||||||
assertEquals(true, range.contains('b'));
|
assertEquals(true, range.contains('b'));
|
||||||
assertEquals(false, range.contains('c'));
|
assertEquals(false, range.contains('c'));
|
||||||
assertEquals(false, range.contains('d'));
|
assertEquals(false, range.contains('d'));
|
||||||
|
@ -240,19 +202,19 @@ public class CharRangeTest extends TestCase {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public void testContains_Charrange() {
|
public void testContains_Charrange() {
|
||||||
CharRange a = new CharRange('a');
|
CharRange a = CharRange.is('a');
|
||||||
CharRange b = new CharRange('b');
|
CharRange b = CharRange.is('b');
|
||||||
CharRange c = new CharRange('c');
|
CharRange c = CharRange.is('c');
|
||||||
CharRange c2 = new CharRange('c');
|
CharRange c2 = CharRange.is('c');
|
||||||
CharRange d = new CharRange('d');
|
CharRange d = CharRange.is('d');
|
||||||
CharRange e = new CharRange('e');
|
CharRange e = CharRange.is('e');
|
||||||
CharRange cd = new CharRange('c', 'd');
|
CharRange cd = CharRange.isIn('c', 'd');
|
||||||
CharRange bd = new CharRange('b', 'd');
|
CharRange bd = CharRange.isIn('b', 'd');
|
||||||
CharRange bc = new CharRange('b', 'c');
|
CharRange bc = CharRange.isIn('b', 'c');
|
||||||
CharRange ab = new CharRange('a', 'b');
|
CharRange ab = CharRange.isIn('a', 'b');
|
||||||
CharRange de = new CharRange('d', 'e');
|
CharRange de = CharRange.isIn('d', 'e');
|
||||||
CharRange ef = new CharRange('e', 'f');
|
CharRange ef = CharRange.isIn('e', 'f');
|
||||||
CharRange ae = new CharRange('a', 'e');
|
CharRange ae = CharRange.isIn('a', 'e');
|
||||||
|
|
||||||
// normal/normal
|
// normal/normal
|
||||||
assertEquals(false, c.contains(b));
|
assertEquals(false, c.contains(b));
|
||||||
|
@ -278,17 +240,17 @@ public class CharRangeTest extends TestCase {
|
||||||
assertEquals(true, ae.contains(cd));
|
assertEquals(true, ae.contains(cd));
|
||||||
assertEquals(true, ae.contains(de));
|
assertEquals(true, ae.contains(de));
|
||||||
|
|
||||||
CharRange notb = new CharRange('b', 'b', true);
|
CharRange notb = CharRange.isNot('b');
|
||||||
CharRange notc = new CharRange('c', 'c', true);
|
CharRange notc = CharRange.isNot('c');
|
||||||
CharRange notd = new CharRange('d', 'd', true);
|
CharRange notd = CharRange.isNot('d');
|
||||||
CharRange notab = new CharRange('a', 'b', true);
|
CharRange notab = CharRange.isNotIn('a', 'b');
|
||||||
CharRange notbc = new CharRange('b', 'c', true);
|
CharRange notbc = CharRange.isNotIn('b', 'c');
|
||||||
CharRange notbd = new CharRange('b', 'd', true);
|
CharRange notbd = CharRange.isNotIn('b', 'd');
|
||||||
CharRange notcd = new CharRange('c', 'd', true);
|
CharRange notcd = CharRange.isNotIn('c', 'd');
|
||||||
CharRange notde = new CharRange('d', 'e', true);
|
CharRange notde = CharRange.isNotIn('d', 'e');
|
||||||
CharRange notae = new CharRange('a', 'e', true);
|
CharRange notae = CharRange.isNotIn('a', 'e');
|
||||||
CharRange all = new CharRange((char) 0, Character.MAX_VALUE);
|
CharRange all = CharRange.isIn((char) 0, Character.MAX_VALUE);
|
||||||
CharRange allbutfirst = new CharRange((char) 1, Character.MAX_VALUE);
|
CharRange allbutfirst = CharRange.isIn((char) 1, Character.MAX_VALUE);
|
||||||
|
|
||||||
// normal/negated
|
// normal/negated
|
||||||
assertEquals(false, c.contains(notc));
|
assertEquals(false, c.contains(notc));
|
||||||
|
@ -354,7 +316,7 @@ public class CharRangeTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testContainsNullArg() {
|
public void testContainsNullArg() {
|
||||||
CharRange range = new CharRange('a');
|
CharRange range = CharRange.is('a');
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
boolean contains = range.contains(null);
|
boolean contains = range.contains(null);
|
||||||
|
@ -365,11 +327,11 @@ public class CharRangeTest extends TestCase {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public void testSerialization() {
|
public void testSerialization() {
|
||||||
CharRange range = new CharRange('a');
|
CharRange range = CharRange.is('a');
|
||||||
assertEquals(range, SerializationUtils.clone(range));
|
assertEquals(range, SerializationUtils.clone(range));
|
||||||
range = new CharRange('a', 'e');
|
range = CharRange.isIn('a', 'e');
|
||||||
assertEquals(range, SerializationUtils.clone(range));
|
assertEquals(range, SerializationUtils.clone(range));
|
||||||
range = new CharRange('a', 'e', true);
|
range = CharRange.isNotIn('a', 'e');
|
||||||
assertEquals(range, SerializationUtils.clone(range));
|
assertEquals(range, SerializationUtils.clone(range));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,35 +130,35 @@ public class CharSetTest extends TestCase {
|
||||||
set = CharSet.getInstance("abc");
|
set = CharSet.getInstance("abc");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(3, array.length);
|
assertEquals(3, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
|
||||||
|
|
||||||
set = CharSet.getInstance("a-ce-f");
|
set = CharSet.getInstance("a-ce-f");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'c')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', 'c')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
|
||||||
|
|
||||||
set = CharSet.getInstance("ae-f");
|
set = CharSet.getInstance("ae-f");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
|
||||||
|
|
||||||
set = CharSet.getInstance("e-fa");
|
set = CharSet.getInstance("e-fa");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
|
||||||
|
|
||||||
set = CharSet.getInstance("ae-fm-pz");
|
set = CharSet.getInstance("ae-fm-pz");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(4, array.length);
|
assertEquals(4, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('e', 'f')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('e', 'f')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('m', 'p')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('m', 'p')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('z')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('z')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructor_String_comboNegated() {
|
public void testConstructor_String_comboNegated() {
|
||||||
|
@ -168,37 +168,37 @@ public class CharSetTest extends TestCase {
|
||||||
set = CharSet.getInstance("^abc");
|
set = CharSet.getInstance("^abc");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(3, array.length);
|
assertEquals(3, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
|
||||||
|
|
||||||
set = CharSet.getInstance("b^ac");
|
set = CharSet.getInstance("b^ac");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(3, array.length);
|
assertEquals(3, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
|
||||||
|
|
||||||
set = CharSet.getInstance("db^ac");
|
set = CharSet.getInstance("db^ac");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(4, array.length);
|
assertEquals(4, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('d')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('d')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('c')));
|
||||||
|
|
||||||
set = CharSet.getInstance("^b^a");
|
set = CharSet.getInstance("^b^a");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('b', 'b', true)));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('b')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true)));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a')));
|
||||||
|
|
||||||
set = CharSet.getInstance("b^a-c^z");
|
set = CharSet.getInstance("b^a-c^z");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(3, array.length);
|
assertEquals(3, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'c', true)));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('a', 'c')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('z', 'z', true)));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('z')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('b')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('b')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructor_String_oddDash() {
|
public void testConstructor_String_oddDash() {
|
||||||
|
@ -208,44 +208,44 @@ public class CharSetTest extends TestCase {
|
||||||
set = CharSet.getInstance("-");
|
set = CharSet.getInstance("-");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
|
||||||
|
|
||||||
set = CharSet.getInstance("--");
|
set = CharSet.getInstance("--");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
|
||||||
|
|
||||||
set = CharSet.getInstance("---");
|
set = CharSet.getInstance("---");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
|
||||||
|
|
||||||
set = CharSet.getInstance("----");
|
set = CharSet.getInstance("----");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
|
||||||
|
|
||||||
set = CharSet.getInstance("-a");
|
set = CharSet.getInstance("-a");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
|
||||||
|
|
||||||
set = CharSet.getInstance("a-");
|
set = CharSet.getInstance("a-");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('a')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-')));
|
||||||
|
|
||||||
set = CharSet.getInstance("a--");
|
set = CharSet.getInstance("a--");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', '-')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', '-')));
|
||||||
|
|
||||||
set = CharSet.getInstance("--a");
|
set = CharSet.getInstance("--a");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-', 'a')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('-', 'a')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructor_String_oddNegate() {
|
public void testConstructor_String_oddNegate() {
|
||||||
|
@ -254,57 +254,57 @@ public class CharSetTest extends TestCase {
|
||||||
set = CharSet.getInstance("^");
|
set = CharSet.getInstance("^");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^'))); // "^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('^'))); // "^"
|
||||||
|
|
||||||
set = CharSet.getInstance("^^");
|
set = CharSet.getInstance("^^");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); // "^^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^"
|
||||||
|
|
||||||
set = CharSet.getInstance("^^^");
|
set = CharSet.getInstance("^^^");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); // "^^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^"
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^'))); // "^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('^'))); // "^"
|
||||||
|
|
||||||
set = CharSet.getInstance("^^^^");
|
set = CharSet.getInstance("^^^^");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); // "^^" x2
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" x2
|
||||||
|
|
||||||
set = CharSet.getInstance("a^");
|
set = CharSet.getInstance("a^");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a'))); // "a"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('a'))); // "a"
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^'))); // "^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('^'))); // "^"
|
||||||
|
|
||||||
set = CharSet.getInstance("^a-");
|
set = CharSet.getInstance("^a-");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'a', true))); // "^a"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('a'))); // "^a"
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-'))); // "-"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-'))); // "-"
|
||||||
|
|
||||||
set = CharSet.getInstance("^^-c");
|
set = CharSet.getInstance("^^-c");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^', 'c', true))); // "^^-c"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('^', 'c'))); // "^^-c"
|
||||||
|
|
||||||
set = CharSet.getInstance("^c-^");
|
set = CharSet.getInstance("^c-^");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c', '^', true))); // "^c-^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^"
|
||||||
|
|
||||||
set = CharSet.getInstance("^c-^d");
|
set = CharSet.getInstance("^c-^d");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c', '^', true))); // "^c-^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^"
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('d'))); // "d"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('d'))); // "d"
|
||||||
|
|
||||||
set = CharSet.getInstance("^^-");
|
set = CharSet.getInstance("^^-");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^', '^', true))); // "^^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^"
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-'))); // "-"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('-'))); // "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructor_String_oddCombinations() {
|
public void testConstructor_String_oddCombinations() {
|
||||||
|
@ -313,8 +313,8 @@ public class CharSetTest extends TestCase {
|
||||||
|
|
||||||
set = CharSet.getInstance("a-^c");
|
set = CharSet.getInstance("a-^c");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', '^'))); // "a-^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', '^'))); // "a-^"
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c'))); // "c"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('c'))); // "c"
|
||||||
assertEquals(false, set.contains('b'));
|
assertEquals(false, set.contains('b'));
|
||||||
assertEquals(true, set.contains('^'));
|
assertEquals(true, set.contains('^'));
|
||||||
assertEquals(true, set.contains('_')); // between ^ and a
|
assertEquals(true, set.contains('_')); // between ^ and a
|
||||||
|
@ -322,16 +322,16 @@ public class CharSetTest extends TestCase {
|
||||||
|
|
||||||
set = CharSet.getInstance("^a-^c");
|
set = CharSet.getInstance("^a-^c");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', '^', true))); // "^a-^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('a', '^'))); // "^a-^"
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('c'))); // "c"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.is('c'))); // "c"
|
||||||
assertEquals(true, set.contains('b'));
|
assertEquals(true, set.contains('b'));
|
||||||
assertEquals(false, set.contains('^'));
|
assertEquals(false, set.contains('^'));
|
||||||
assertEquals(false, set.contains('_')); // between ^ and a
|
assertEquals(false, set.contains('_')); // between ^ and a
|
||||||
|
|
||||||
set = CharSet.getInstance("a- ^-- "); //contains everything
|
set = CharSet.getInstance("a- ^-- "); //contains everything
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', ' '))); // "a- "
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', ' '))); // "a- "
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('-', ' ', true))); // "^-- "
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isNotIn('-', ' '))); // "^-- "
|
||||||
assertEquals(true, set.contains('#'));
|
assertEquals(true, set.contains('#'));
|
||||||
assertEquals(true, set.contains('^'));
|
assertEquals(true, set.contains('^'));
|
||||||
assertEquals(true, set.contains('a'));
|
assertEquals(true, set.contains('a'));
|
||||||
|
@ -340,7 +340,7 @@ public class CharSetTest extends TestCase {
|
||||||
|
|
||||||
set = CharSet.getInstance("^-b");
|
set = CharSet.getInstance("^-b");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^','b'))); // "^-b"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "^-b"
|
||||||
assertEquals(true, set.contains('b'));
|
assertEquals(true, set.contains('b'));
|
||||||
assertEquals(true, set.contains('_')); // between ^ and a
|
assertEquals(true, set.contains('_')); // between ^ and a
|
||||||
assertEquals(false, set.contains('A'));
|
assertEquals(false, set.contains('A'));
|
||||||
|
@ -348,7 +348,7 @@ public class CharSetTest extends TestCase {
|
||||||
|
|
||||||
set = CharSet.getInstance("b-^");
|
set = CharSet.getInstance("b-^");
|
||||||
array = set.getCharRanges();
|
array = set.getCharRanges();
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('^','b'))); // "b-^"
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "b-^"
|
||||||
assertEquals(true, set.contains('b'));
|
assertEquals(true, set.contains('b'));
|
||||||
assertEquals(true, set.contains('^'));
|
assertEquals(true, set.contains('^'));
|
||||||
assertEquals(true, set.contains('a')); // between ^ and b
|
assertEquals(true, set.contains('a')); // between ^ and b
|
||||||
|
@ -460,20 +460,20 @@ public class CharSetTest extends TestCase {
|
||||||
|
|
||||||
array = CharSet.ASCII_ALPHA.getCharRanges();
|
array = CharSet.ASCII_ALPHA.getCharRanges();
|
||||||
assertEquals(2, array.length);
|
assertEquals(2, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'z')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', 'z')));
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('A', 'Z')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('A', 'Z')));
|
||||||
|
|
||||||
array = CharSet.ASCII_ALPHA_LOWER.getCharRanges();
|
array = CharSet.ASCII_ALPHA_LOWER.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('a', 'z')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('a', 'z')));
|
||||||
|
|
||||||
array = CharSet.ASCII_ALPHA_UPPER.getCharRanges();
|
array = CharSet.ASCII_ALPHA_UPPER.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('A', 'Z')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('A', 'Z')));
|
||||||
|
|
||||||
array = CharSet.ASCII_NUMERIC.getCharRanges();
|
array = CharSet.ASCII_NUMERIC.getCharRanges();
|
||||||
assertEquals(1, array.length);
|
assertEquals(1, array.length);
|
||||||
assertEquals(true, ArrayUtils.contains(array, new CharRange('0', '9')));
|
assertEquals(true, ArrayUtils.contains(array, CharRange.isIn('0', '9')));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue