1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary.validation;
17
18 import org.kuali.rice.kns.datadictionary.validation.ValidationPattern;
19
20 import junit.framework.AssertionFailedError;
21
22 public class UTF8ValidationTestUtils {
23 static final String[] TEST_INPUTS = { "", "!!!", "[a-9]", "^A-Z", "abc", "a bc", "a_bc", "123", "12 3", "12_3",
24 "a1b2c3", "a1b2_c3", "a 1b2c3", "a 1b2_c3", "foo.bar", "foo.bar_baz", ".bar_foo baz",
25 "!\"#abs$%&'()*+,./:;<=abs>?@\\^_abs`{|}~-", "\u00E6\u00E6", "\t", "\u00E6 \u00E6"};
26
27 public static final void assertPatternMatches(ValidationPattern pattern, boolean[] expectedValues) {
28
29 if (expectedValues.length != TEST_INPUTS.length) {
30 throw new AssertionFailedError("expectedValues length was " + expectedValues.length + ", expected TEST_INPUTS.length of " + TEST_INPUTS.length);
31 }
32
33 for (int i = 0; i < TEST_INPUTS.length; ++i) {
34 String testInput = TEST_INPUTS[i];
35 boolean expectedResult = expectedValues[i];
36
37 boolean actualResult = pattern.matches(testInput);
38 if (actualResult != expectedResult) {
39 throw new AssertionFailedError("for input '" + testInput + "', expected " + expectedResult + " but got " + actualResult);
40 }
41 }
42 }
43 }