@Test public void test_toIntegerObject_boolean_Integer_Integer() { Integer six = Integer.valueOf(6); Integer seven = Integer.valueOf(7); assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven)); assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven)); }
@Test public void test_toBooleanObject_Integer() { assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1))); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(-1))); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0))); assertEquals(null, BooleanUtils.toBooleanObject((Integer) null)); }
// ----------------------------------------------------------------------- public void test_toBoolean_int_int_int() { assertEquals(true, BooleanUtils.toBoolean(6, 6, 7)); assertEquals(false, BooleanUtils.toBoolean(7, 6, 7)); try { BooleanUtils.toBoolean(8, 6, 7); fail(); } catch (IllegalArgumentException ex) { } }
public void test_toIntegerObject_Boolean_Integer_Integer_Integer() { Integer six = new Integer(6); Integer seven = new Integer(7); Integer eight = new Integer(8); assertEquals(six, BooleanUtils.toIntegerObject(Boolean.TRUE, six, seven, eight)); assertEquals(seven, BooleanUtils.toIntegerObject(Boolean.FALSE, six, seven, eight)); assertEquals(eight, BooleanUtils.toIntegerObject((Boolean) null, six, seven, eight)); assertEquals(null, BooleanUtils.toIntegerObject((Boolean) null, six, seven, null)); }
public void testXor_primitive_validInput_2items() { assertTrue("True result for (true, true)", !BooleanUtils.xor(new boolean[] {true, true})); assertTrue("True result for (false, false)", !BooleanUtils.xor(new boolean[] {false, false})); assertTrue("False result for (true, false)", BooleanUtils.xor(new boolean[] {true, false})); assertTrue("False result for (false, true)", BooleanUtils.xor(new boolean[] {false, true})); }
// ----------------------------------------------------------------------- public void test_toBooleanObject_int_int_int() { assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(6, 6, 7, 8)); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(7, 6, 7, 8)); assertEquals(null, BooleanUtils.toBooleanObject(8, 6, 7, 8)); try { BooleanUtils.toBooleanObject(9, 6, 7, 8); fail(); } catch (IllegalArgumentException ex) { } }
@Test public void test_toBoolean_Integer_Integer_Integer() { Integer six = Integer.valueOf(6); Integer seven = Integer.valueOf(7); assertEquals(true, BooleanUtils.toBoolean((Integer) null, null, seven)); assertEquals(false, BooleanUtils.toBoolean((Integer) null, six, null)); assertEquals(true, BooleanUtils.toBoolean(Integer.valueOf(6), six, seven)); assertEquals(false, BooleanUtils.toBoolean(Integer.valueOf(7), six, seven)); }
@Test public void testOr_object_validInput_3items() { assertTrue( "False result for (false, false, true)", BooleanUtils.or(new Boolean[] {Boolean.FALSE, Boolean.FALSE, Boolean.TRUE}).booleanValue()); assertTrue( "False result for (false, true, false)", BooleanUtils.or(new Boolean[] {Boolean.FALSE, Boolean.TRUE, Boolean.FALSE}).booleanValue()); assertTrue( "False result for (true, false, false)", BooleanUtils.or(new Boolean[] {Boolean.TRUE, Boolean.FALSE, Boolean.FALSE}).booleanValue()); assertTrue( "False result for (true, true, true)", BooleanUtils.or(new Boolean[] {Boolean.TRUE, Boolean.TRUE, Boolean.TRUE}).booleanValue()); assertTrue( "True result for (false, false)", !BooleanUtils.or(new Boolean[] {Boolean.FALSE, Boolean.FALSE, Boolean.FALSE}) .booleanValue()); assertTrue( "False result for (true, true, false)", BooleanUtils.or(new Boolean[] {Boolean.TRUE, Boolean.TRUE, Boolean.FALSE}).booleanValue()); assertTrue( "False result for (true, false, true)", BooleanUtils.or(new Boolean[] {Boolean.TRUE, Boolean.FALSE, Boolean.TRUE}).booleanValue()); assertTrue( "False result for (false, true, true)", BooleanUtils.or(new Boolean[] {Boolean.FALSE, Boolean.TRUE, Boolean.TRUE}).booleanValue()); }
@Test public void test_toBoolean_String_String_String() { assertEquals(true, BooleanUtils.toBoolean((String) null, null, "N")); assertEquals(false, BooleanUtils.toBoolean((String) null, "Y", null)); assertEquals(true, BooleanUtils.toBoolean("Y", "Y", "N")); assertEquals(true, BooleanUtils.toBoolean("Y", new String("Y"), new String("N"))); assertEquals(false, BooleanUtils.toBoolean("N", "Y", "N")); assertEquals(false, BooleanUtils.toBoolean("N", new String("Y"), new String("N"))); assertEquals(true, BooleanUtils.toBoolean((String) null, null, null)); assertEquals(true, BooleanUtils.toBoolean("Y", "Y", "Y")); assertEquals(true, BooleanUtils.toBoolean("Y", new String("Y"), new String("Y"))); }
public void testXor_object_nullElementInput() { try { BooleanUtils.xor(new Boolean[] {null}); fail("Exception was not thrown for null element input."); } catch (IllegalArgumentException ex) { } }
public void testXor_object_emptyInput() { try { BooleanUtils.xor(new Boolean[] {}); fail("Exception was not thrown for empty input."); } catch (IllegalArgumentException ex) { } }
public void testXor_object_nullInput() { final Boolean[] b = null; try { BooleanUtils.xor(b); fail("Exception was not thrown for null input."); } catch (IllegalArgumentException ex) { } }
public void test_toBooleanDefaultIfNull_Boolean_boolean() { assertEquals(true, BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, true)); assertEquals(true, BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false)); assertEquals(false, BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true)); assertEquals(false, BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, false)); assertEquals(true, BooleanUtils.toBooleanDefaultIfNull((Boolean) null, true)); assertEquals(false, BooleanUtils.toBooleanDefaultIfNull((Boolean) null, false)); }
@Test public void test_toBooleanObject_String_String_String_String() { assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((String) null, null, "N", "U")); assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((String) null, "Y", null, "U")); assertSame(null, BooleanUtils.toBooleanObject((String) null, "Y", "N", null)); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U")); assertEquals(null, BooleanUtils.toBooleanObject("U", "Y", "N", "U")); }
public void test_toBooleanObject_String_String_String_String() { assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((String) null, null, "N", "U")); assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((String) null, "Y", null, "U")); assertSame(null, BooleanUtils.toBooleanObject((String) null, "Y", "N", null)); try { BooleanUtils.toBooleanObject((String) null, "Y", "N", "U"); fail(); } catch (IllegalArgumentException ex) { } assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U")); assertEquals(null, BooleanUtils.toBooleanObject("U", "Y", "N", "U")); try { BooleanUtils.toBooleanObject(null, "Y", "N", "U"); fail(); } catch (IllegalArgumentException ex) { } try { BooleanUtils.toBooleanObject("X", "Y", "N", "U"); fail(); } catch (IllegalArgumentException ex) { } }
@Test public void test_toBooleanObject_Integer_Integer_Integer_Integer() { Integer six = Integer.valueOf(6); Integer seven = Integer.valueOf(7); Integer eight = Integer.valueOf(8); assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight)); assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight)); assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null)); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(6), six, seven, eight)); assertEquals( Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(7), six, seven, eight)); assertEquals(null, BooleanUtils.toBooleanObject(Integer.valueOf(8), six, seven, eight)); }
public void test_toBooleanObject_Integer_Integer_Integer_Integer() { Integer six = new Integer(6); Integer seven = new Integer(7); Integer eight = new Integer(8); assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight)); assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight)); assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null)); try { BooleanUtils.toBooleanObject(null, six, seven, eight); fail(); } catch (IllegalArgumentException ex) { } assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(6), six, seven, eight)); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(7), six, seven, eight)); assertEquals(null, BooleanUtils.toBooleanObject(new Integer(8), six, seven, eight)); try { BooleanUtils.toBooleanObject(new Integer(9), six, seven, eight); fail(); } catch (IllegalArgumentException ex) { } }
public void test_toBoolean_String_String_String() { assertEquals(true, BooleanUtils.toBoolean((String) null, null, "N")); assertEquals(false, BooleanUtils.toBoolean((String) null, "Y", null)); try { BooleanUtils.toBooleanObject((String) null, "Y", "N", "U"); fail(); } catch (IllegalArgumentException ex) { } assertEquals(true, BooleanUtils.toBoolean("Y", "Y", "N")); assertEquals(false, BooleanUtils.toBoolean("N", "Y", "N")); try { BooleanUtils.toBoolean(null, "Y", "N"); fail(); } catch (IllegalArgumentException ex) { } try { BooleanUtils.toBoolean("X", "Y", "N"); fail(); } catch (IllegalArgumentException ex) { } }
public void test_toBoolean_Integer_Integer_Integer() { Integer six = new Integer(6); Integer seven = new Integer(7); assertEquals(true, BooleanUtils.toBoolean((Integer) null, null, seven)); assertEquals(false, BooleanUtils.toBoolean((Integer) null, six, null)); try { BooleanUtils.toBoolean(null, six, seven); fail(); } catch (IllegalArgumentException ex) { } assertEquals(true, BooleanUtils.toBoolean(new Integer(6), six, seven)); assertEquals(false, BooleanUtils.toBoolean(new Integer(7), six, seven)); try { BooleanUtils.toBoolean(new Integer(8), six, seven); fail(); } catch (IllegalArgumentException ex) { } }
public void test_toInteger_Boolean_int_int_int() { assertEquals(6, BooleanUtils.toInteger(Boolean.TRUE, 6, 7, 8)); assertEquals(7, BooleanUtils.toInteger(Boolean.FALSE, 6, 7, 8)); assertEquals(8, BooleanUtils.toInteger(null, 6, 7, 8)); }
public void test_toStringYesNo_Boolean() { assertEquals(null, BooleanUtils.toStringYesNo((Boolean) null)); assertEquals("yes", BooleanUtils.toStringYesNo(Boolean.TRUE)); assertEquals("no", BooleanUtils.toStringYesNo(Boolean.FALSE)); }
// ----------------------------------------------------------------------- public void test_toBoolean_String() { assertEquals(false, BooleanUtils.toBoolean((String) null)); assertEquals(false, BooleanUtils.toBoolean("")); assertEquals(false, BooleanUtils.toBoolean("off")); assertEquals(false, BooleanUtils.toBoolean("oof")); assertEquals(true, BooleanUtils.toBoolean("true")); assertEquals(true, BooleanUtils.toBoolean("yes")); assertEquals(true, BooleanUtils.toBoolean("on")); assertEquals(true, BooleanUtils.toBoolean("TRUE")); assertEquals(true, BooleanUtils.toBoolean("ON")); assertEquals(true, BooleanUtils.toBoolean("YES")); assertEquals(true, BooleanUtils.toBoolean("TruE")); }
// ----------------------------------------------------------------------- // ----------------------------------------------------------------------- public void test_toBooleanObject_String() { assertEquals(null, BooleanUtils.toBooleanObject((String) null)); assertEquals(null, BooleanUtils.toBooleanObject("")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("false")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("no")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("off")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("FALSE")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("NO")); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("OFF")); assertEquals(null, BooleanUtils.toBooleanObject("oof")); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("true")); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("yes")); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("on")); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TRUE")); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("ON")); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("YES")); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE")); }
public void test_toStringYesNo_boolean() { assertEquals("yes", BooleanUtils.toStringYesNo(true)); assertEquals("no", BooleanUtils.toStringYesNo(false)); }
public void test_toString_boolean_String_String_String() { assertEquals("Y", BooleanUtils.toString(true, "Y", "N")); assertEquals("N", BooleanUtils.toString(false, "Y", "N")); }
public void test_toStringOnOff_boolean() { assertEquals("on", BooleanUtils.toStringOnOff(true)); assertEquals("off", BooleanUtils.toStringOnOff(false)); }
// ----------------------------------------------------------------------- public void test_toStringTrueFalse_boolean() { assertEquals("true", BooleanUtils.toStringTrueFalse(true)); assertEquals("false", BooleanUtils.toStringTrueFalse(false)); }
public void test_toString_Boolean_String_String_String() { assertEquals("U", BooleanUtils.toString((Boolean) null, "Y", "N", "U")); assertEquals("Y", BooleanUtils.toString(Boolean.TRUE, "Y", "N", "U")); assertEquals("N", BooleanUtils.toString(Boolean.FALSE, "Y", "N", "U")); }
// ----------------------------------------------------------------------- public void test_toStringTrueFalse_Boolean() { assertEquals(null, BooleanUtils.toStringTrueFalse((Boolean) null)); assertEquals("true", BooleanUtils.toStringTrueFalse(Boolean.TRUE)); assertEquals("false", BooleanUtils.toStringTrueFalse(Boolean.FALSE)); }
public void test_toStringOnOff_Boolean() { assertEquals(null, BooleanUtils.toStringOnOff((Boolean) null)); assertEquals("on", BooleanUtils.toStringOnOff(Boolean.TRUE)); assertEquals("off", BooleanUtils.toStringOnOff(Boolean.FALSE)); }