Skip to content

Commit

Permalink
fix related overly-strict tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahgittin committed Feb 11, 2019
1 parent 69b9c8b commit 98e335b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -82,7 +82,7 @@ public void testCoerceStringToPrimitive() {
assertEquals(TypeCoercions.coerce("1", short.class), (Short)((short)1));
assertEquals(TypeCoercions.coerce("1", int.class), (Integer)1);
assertEquals(TypeCoercions.coerce("1", long.class), (Long)1l);
assertEquals(TypeCoercions.coerce("1", float.class), 1f);
assertEquals(TypeCoercions.coerce("1", float.cfboolelass), 1f);
assertEquals(TypeCoercions.coerce("1", double.class), 1d);
assertEquals(TypeCoercions.coerce("TRUE", boolean.class), (Boolean)true);
assertEquals(TypeCoercions.coerce("false", boolean.class), (Boolean)false);
Expand Down Expand Up @@ -129,10 +129,10 @@ public void testCastPrimitives() {
@Test
public void testCoercePrimitiveFailures() {
// error messages don't have to be this exactly, but they should include sufficient information...
assertCoercionFailsWithErrorMatching("maybe", boolean.class, StringPredicates.containsAllLiterals("String", "boolean", "maybe"));
assertCoercionFailsWithErrorMatching("NaN", int.class, StringPredicates.containsAllLiterals("int", "NaN"));
assertCoercionFailsWithErrorMatching('c', boolean.class, StringPredicates.containsAllLiterals("boolean", "(c)")); // will say 'string' rather than 'char'
assertCoercionFailsWithErrorMatching(0, boolean.class, StringPredicates.containsAllLiterals("Integer", "boolean", "0"));
assertCoercionFailsWithErrorMatching("maybe", boolean.class, StringPredicates.containsAllLiterals("String", "Boolean", "maybe"));
assertCoercionFailsWithErrorMatching("NaN", int.class, StringPredicates.containsAllLiterals("Integer", "NaN"));
assertCoercionFailsWithErrorMatching('c', boolean.class, StringPredicates.containsAllLiterals("Boolean", "(c)")); // will say 'string' rather than 'char'
assertCoercionFailsWithErrorMatching(0, boolean.class, StringPredicates.containsAllLiterals("Integer", "Boolean", "0"));
}

protected void assertCoercionFailsWithErrorMatching(Object input, Class<?> type, Predicate<? super String> errorMessageRequirement) {
Expand Down
Expand Up @@ -137,10 +137,10 @@ public void testCastPrimitives() {
@Test
public void testCoercePrimitiveFailures() {
// error messages don't have to be this exactly, but they should include sufficient information...
assertCoercionFailsWithErrorMatching("maybe", boolean.class, StringPredicates.containsAllLiterals("String", "boolean", "maybe"));
assertCoercionFailsWithErrorMatching("NaN", int.class, StringPredicates.containsAllLiterals("int", "NaN"));
assertCoercionFailsWithErrorMatching('c', boolean.class, StringPredicates.containsAllLiterals("boolean", "(c)")); // will say 'string' rather than 'char'
assertCoercionFailsWithErrorMatching(0, boolean.class, StringPredicates.containsAllLiterals("Integer", "boolean", "0"));
assertCoercionFailsWithErrorMatching("maybe", boolean.class, StringPredicates.containsAllLiterals("String", "Boolean", "maybe"));
assertCoercionFailsWithErrorMatching("NaN", int.class, StringPredicates.containsAllLiterals("Integer", "NaN"));
assertCoercionFailsWithErrorMatching('c', boolean.class, StringPredicates.containsAllLiterals("Boolean", "(c)")); // will say 'string' rather than 'char'
assertCoercionFailsWithErrorMatching(0, boolean.class, StringPredicates.containsAllLiterals("Integer", "Boolean", "0"));
}

protected void assertCoercionFailsWithErrorMatching(Object input, Class<?> type, Predicate<? super String> errorMessageRequirement) {
Expand Down

0 comments on commit 98e335b

Please sign in to comment.