Skip to content

Commit

Permalink
Expected result must come first
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Dec 21, 2024
1 parent 7995424 commit 902d086
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/test/java/org/apache/commons/validator/VarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ public void testVars() {
assertEquals("value-2-1", var21.getValue(), "var-2-1 value is wrong");
assertEquals("jstype-2-1", var21.getJsType(), "var-2-1 jstype is wrong");
assertTrue(var21.isResource(), "var-2-1 resource is false");
assertEquals(var21.getBundle(), "bundle-2-1", "var-2-1 bundle is wrong");
assertEquals("bundle-2-1", var21.getBundle(), "var-2-1 bundle is wrong");

// Get var-2-2
final Var var22 = field2.getVar("var-2-2");
assertNotNull(var22, "var-2-2 is null.");
assertEquals(var22.getName(), "var-2-2", "var-2-2 name is wrong");
assertEquals(var22.getValue(), "value-2-2", "var-2-2 value is wrong");
assertEquals("var-2-2", var22.getName(), "var-2-2 name is wrong");
assertEquals("value-2-2", var22.getValue(), "var-2-2 value is wrong");
assertNull(var22.getJsType(), "var-2-2 jstype is not null");
assertFalse(var22.isResource(), "var-2-2 resource is true");
assertEquals(var22.getBundle(), "bundle-2-2", "var-2-2 bundle is wrong");
assertEquals("bundle-2-2", var22.getBundle(), "var-2-2 bundle is wrong");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,17 @@ public void testSingle() {
assertFalse(insensitive.isValid("ABd-de-1"), "Insensitive isValid() invalid");

// validate()
assertEquals(sensitive.validate("ac-DE-1"), "acDE1", "Sensitive validate() valid");
assertEquals("acDE1", sensitive.validate("ac-DE-1"), "Sensitive validate() valid");
assertNull(sensitive.validate("AB-de-1"), "Sensitive validate() invalid");
assertEquals(insensitive.validate("AB-de-1"), "ABde1", "Insensitive validate() valid");
assertEquals("ABde1", insensitive.validate("AB-de-1"), "Insensitive validate() valid");
assertNull(insensitive.validate("ABd-de-1"), "Insensitive validate() invalid");

// match()
checkArray("Sensitive match() valid", new String[] { "ac", "DE", "1" }, sensitive.match("ac-DE-1"));
checkArray("Sensitive match() invalid", null, sensitive.match("AB-de-1"));
checkArray("Insensitive match() valid", new String[] { "AB", "de", "1" }, insensitive.match("AB-de-1"));
checkArray("Insensitive match() invalid", null, insensitive.match("ABd-de-1"));
assertEquals(new RegexValidator("^([A-Z]*)$").validate("ABC"), "ABC", "validate one");
assertEquals("ABC", new RegexValidator("^([A-Z]*)$").validate("ABC"), "validate one");
checkArray("match one", new String[] { "ABC" }, new RegexValidator("^([A-Z]*)$").match("ABC"));
}

Expand All @@ -260,10 +260,10 @@ public void testSingle() {
@Test
public void testToString() {
final RegexValidator single = new RegexValidator(REGEX);
assertEquals(single.toString(), "RegexValidator{" + REGEX + "}", "Single");
assertEquals("RegexValidator{" + REGEX + "}", single.toString(), "Single");

final RegexValidator multiple = new RegexValidator(REGEX, REGEX);
assertEquals(multiple.toString(), "RegexValidator{" + REGEX + "," + REGEX + "}", "Multiple");
assertEquals("RegexValidator{" + REGEX + "," + REGEX + "}", multiple.toString(), "Multiple");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testInvalidLength() {
assertFalse(routine.isValid("12345678901234"), "isValid() Lth 14");

Exception e = assertThrows(CheckDigitException.class, () -> routine.calculate("12345678"), "calculate() Lth 8");
assertEquals(e.getMessage(), "Invalid ISBN Length = 8", "calculate() Lth 8");
assertEquals("Invalid ISBN Length = 8", e.getMessage(), "calculate() Lth 8");

e = assertThrows(CheckDigitException.class, () -> routine.calculate("1234567890"), "calculate() Lth 10");
assertEquals("Invalid ISBN Length = 10", e.getMessage(), "calculate() Lth 10");
Expand Down

0 comments on commit 902d086

Please sign in to comment.