AsciiNumeric implements Comparator { public boolean equals(String string1, String string2) { final boolean result; if (isPositiveInfinity(string1)) { result = isPositiveInfinity(string2); } else { if (isPositiveInfinity(string2)) { result = false; } else { final BigInteger integer1 = toInteger(string1); final BigInteger integer2 = toInteger(string2); result = integer1.equals(integer2); } } return result; } AsciiNumeric(); boolean equals(String string1, String string2); @Override boolean contains(String container, String content); @Override boolean matches(String string, String glob);  }
@Test public void testBasicNumbericEquality() throws Exception { Assert.assertFalse(subject.equals("1", "2")); Assert.assertTrue(subject.equals("1", "1")); }
@Test public void testEqualityShouldIgnoreTrailingCharacters() throws Exception { Assert.assertTrue(subject.equals("01", "1A")); Assert.assertTrue(subject.equals("1", "00000000000000001A")); Assert.assertTrue(subject.equals("234S", "234YTGSDBBSD")); }
@Test public void testEqualityShouldIgnoreLeadingZeros() throws Exception { Assert.assertTrue(subject.equals("01", "1")); Assert.assertTrue(subject.equals("000001", "1")); Assert.assertFalse(subject.equals("000001", "10")); }
@Test public void testStingsThatDoNotStartWithADigitRepresentPositiveInfinityWhenUsedInEquality() throws Exception { Assert.assertFalse(subject.equals("1", "A4")); Assert.assertFalse(subject.equals("x", "4")); Assert.assertTrue(subject.equals("GT", "A4")); }