|
|
|
@ -37,9 +37,9 @@ public class ConstantsTests { |
|
|
|
assertEquals(A.class.getName(), c.getClassName()); |
|
|
|
assertEquals(A.class.getName(), c.getClassName()); |
|
|
|
assertEquals(9, c.getSize()); |
|
|
|
assertEquals(9, c.getSize()); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(c.asNumber("DOG").intValue(), A.DOG); |
|
|
|
assertEquals(A.DOG, c.asNumber("DOG").intValue()); |
|
|
|
assertEquals(c.asNumber("dog").intValue(), A.DOG); |
|
|
|
assertEquals(A.DOG, c.asNumber("dog").intValue()); |
|
|
|
assertEquals(c.asNumber("cat").intValue(), A.CAT); |
|
|
|
assertEquals(A.CAT, c.asNumber("cat").intValue()); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
c.asNumber("bogus"); |
|
|
|
c.asNumber("bogus"); |
|
|
|
@ -152,20 +152,20 @@ public class ConstantsTests { |
|
|
|
public void toCode() { |
|
|
|
public void toCode() { |
|
|
|
Constants c = new Constants(A.class); |
|
|
|
Constants c = new Constants(A.class); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(c.toCode(new Integer(0), ""), "DOG"); |
|
|
|
assertEquals("DOG", c.toCode(new Integer(0), "")); |
|
|
|
assertEquals(c.toCode(new Integer(0), "D"), "DOG"); |
|
|
|
assertEquals("DOG", c.toCode(new Integer(0), "D")); |
|
|
|
assertEquals(c.toCode(new Integer(0), "DO"), "DOG"); |
|
|
|
assertEquals("DOG", c.toCode(new Integer(0), "DO")); |
|
|
|
assertEquals(c.toCode(new Integer(0), "DoG"), "DOG"); |
|
|
|
assertEquals("DOG", c.toCode(new Integer(0), "DoG")); |
|
|
|
assertEquals(c.toCode(new Integer(0), null), "DOG"); |
|
|
|
assertEquals("DOG", c.toCode(new Integer(0), null)); |
|
|
|
assertEquals(c.toCode(new Integer(66), ""), "CAT"); |
|
|
|
assertEquals("CAT", c.toCode(new Integer(66), "")); |
|
|
|
assertEquals(c.toCode(new Integer(66), "C"), "CAT"); |
|
|
|
assertEquals("CAT", c.toCode(new Integer(66), "C")); |
|
|
|
assertEquals(c.toCode(new Integer(66), "ca"), "CAT"); |
|
|
|
assertEquals("CAT", c.toCode(new Integer(66), "ca")); |
|
|
|
assertEquals(c.toCode(new Integer(66), "cAt"), "CAT"); |
|
|
|
assertEquals("CAT", c.toCode(new Integer(66), "cAt")); |
|
|
|
assertEquals(c.toCode(new Integer(66), null), "CAT"); |
|
|
|
assertEquals("CAT", c.toCode(new Integer(66), null)); |
|
|
|
assertEquals(c.toCode("", ""), "S1"); |
|
|
|
assertEquals("S1", c.toCode("", "")); |
|
|
|
assertEquals(c.toCode("", "s"), "S1"); |
|
|
|
assertEquals("S1", c.toCode("", "s")); |
|
|
|
assertEquals(c.toCode("", "s1"), "S1"); |
|
|
|
assertEquals("S1", c.toCode("", "s1")); |
|
|
|
assertEquals(c.toCode("", null), "S1"); |
|
|
|
assertEquals("S1", c.toCode("", null)); |
|
|
|
try { |
|
|
|
try { |
|
|
|
c.toCode("bogus", "bogus"); |
|
|
|
c.toCode("bogus", "bogus"); |
|
|
|
fail("Should have thrown ConstantException"); |
|
|
|
fail("Should have thrown ConstantException"); |
|
|
|
@ -179,8 +179,8 @@ public class ConstantsTests { |
|
|
|
catch (Constants.ConstantException expected) { |
|
|
|
catch (Constants.ConstantException expected) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(c.toCodeForProperty(new Integer(1), "myProperty"), "MY_PROPERTY_NO"); |
|
|
|
assertEquals("MY_PROPERTY_NO", c.toCodeForProperty(new Integer(1), "myProperty")); |
|
|
|
assertEquals(c.toCodeForProperty(new Integer(2), "myProperty"), "MY_PROPERTY_YES"); |
|
|
|
assertEquals("MY_PROPERTY_YES", c.toCodeForProperty(new Integer(2), "myProperty")); |
|
|
|
try { |
|
|
|
try { |
|
|
|
c.toCodeForProperty("bogus", "bogus"); |
|
|
|
c.toCodeForProperty("bogus", "bogus"); |
|
|
|
fail("Should have thrown ConstantException"); |
|
|
|
fail("Should have thrown ConstantException"); |
|
|
|
@ -188,20 +188,20 @@ public class ConstantsTests { |
|
|
|
catch (Constants.ConstantException expected) { |
|
|
|
catch (Constants.ConstantException expected) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(0), ""), "DOG"); |
|
|
|
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(0), "G"), "DOG"); |
|
|
|
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "G")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(0), "OG"), "DOG"); |
|
|
|
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "OG")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(0), "DoG"), "DOG"); |
|
|
|
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "DoG")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(0), null), "DOG"); |
|
|
|
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), null)); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(66), ""), "CAT"); |
|
|
|
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(66), "T"), "CAT"); |
|
|
|
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "T")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(66), "at"), "CAT"); |
|
|
|
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "at")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(66), "cAt"), "CAT"); |
|
|
|
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "cAt")); |
|
|
|
assertEquals(c.toCodeForSuffix(new Integer(66), null), "CAT"); |
|
|
|
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), null)); |
|
|
|
assertEquals(c.toCodeForSuffix("", ""), "S1"); |
|
|
|
assertEquals("S1", c.toCodeForSuffix("", "")); |
|
|
|
assertEquals(c.toCodeForSuffix("", "1"), "S1"); |
|
|
|
assertEquals("S1", c.toCodeForSuffix("", "1")); |
|
|
|
assertEquals(c.toCodeForSuffix("", "s1"), "S1"); |
|
|
|
assertEquals("S1", c.toCodeForSuffix("", "s1")); |
|
|
|
assertEquals(c.toCodeForSuffix("", null), "S1"); |
|
|
|
assertEquals("S1", c.toCodeForSuffix("", null)); |
|
|
|
try { |
|
|
|
try { |
|
|
|
c.toCodeForSuffix("bogus", "bogus"); |
|
|
|
c.toCodeForSuffix("bogus", "bogus"); |
|
|
|
fail("Should have thrown ConstantException"); |
|
|
|
fail("Should have thrown ConstantException"); |
|
|
|
|