예제 #1
0
 // -----------------------------------------------------------------------
 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) {
   }
 }
  @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 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")));
 }
예제 #4
0
  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) {
    }
  }
예제 #5
0
  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) {
    }
  }
예제 #6
0
 // -----------------------------------------------------------------------
 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"));
 }
예제 #7
0
 // -----------------------------------------------------------------------
 // -----------------------------------------------------------------------
 public void test_toBoolean_int() {
   assertEquals(true, BooleanUtils.toBoolean(1));
   assertEquals(true, BooleanUtils.toBoolean(-1));
   assertEquals(false, BooleanUtils.toBoolean(0));
 }
예제 #8
0
 public void test_toBoolean_Boolean() {
   assertEquals(true, BooleanUtils.toBoolean(Boolean.TRUE));
   assertEquals(false, BooleanUtils.toBoolean(Boolean.FALSE));
   assertEquals(false, BooleanUtils.toBoolean((Boolean) null));
 }
 @Test(expected = IllegalArgumentException.class)
 public void test_toBoolean_String_String_String_noMatch() {
   BooleanUtils.toBoolean("X", "Y", "N");
 }
예제 #10
0
 @Test(expected = IllegalArgumentException.class)
 public void test_toBoolean_String_String_String_nullValue() {
   BooleanUtils.toBoolean(null, "Y", "N");
 }
예제 #11
0
  // -----------------------------------------------------------------------
  @Test
  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(false, BooleanUtils.toBoolean("yep"));
    assertEquals(false, BooleanUtils.toBoolean("trux"));
    assertEquals(false, BooleanUtils.toBoolean("false"));
    assertEquals(false, BooleanUtils.toBoolean("a"));
    assertEquals(true, BooleanUtils.toBoolean("true")); // interned handled differently
    assertEquals(true, BooleanUtils.toBoolean(new StringBuffer("tr").append("ue").toString()));
    assertEquals(true, BooleanUtils.toBoolean("truE"));
    assertEquals(true, BooleanUtils.toBoolean("trUe"));
    assertEquals(true, BooleanUtils.toBoolean("trUE"));
    assertEquals(true, BooleanUtils.toBoolean("tRue"));
    assertEquals(true, BooleanUtils.toBoolean("tRuE"));
    assertEquals(true, BooleanUtils.toBoolean("tRUe"));
    assertEquals(true, BooleanUtils.toBoolean("tRUE"));
    assertEquals(true, BooleanUtils.toBoolean("TRUE"));
    assertEquals(true, BooleanUtils.toBoolean("TRUe"));
    assertEquals(true, BooleanUtils.toBoolean("TRuE"));
    assertEquals(true, BooleanUtils.toBoolean("TRue"));
    assertEquals(true, BooleanUtils.toBoolean("TrUE"));
    assertEquals(true, BooleanUtils.toBoolean("TrUe"));
    assertEquals(true, BooleanUtils.toBoolean("TruE"));
    assertEquals(true, BooleanUtils.toBoolean("True"));
    assertEquals(true, BooleanUtils.toBoolean("on"));
    assertEquals(true, BooleanUtils.toBoolean("oN"));
    assertEquals(true, BooleanUtils.toBoolean("On"));
    assertEquals(true, BooleanUtils.toBoolean("ON"));
    assertEquals(true, BooleanUtils.toBoolean("yes"));
    assertEquals(true, BooleanUtils.toBoolean("yeS"));
    assertEquals(true, BooleanUtils.toBoolean("yEs"));
    assertEquals(true, BooleanUtils.toBoolean("yES"));
    assertEquals(true, BooleanUtils.toBoolean("Yes"));
    assertEquals(true, BooleanUtils.toBoolean("YeS"));
    assertEquals(true, BooleanUtils.toBoolean("YEs"));
    assertEquals(true, BooleanUtils.toBoolean("YES"));
    assertEquals(false, BooleanUtils.toBoolean("yes?"));
    assertEquals(false, BooleanUtils.toBoolean("tru"));

    assertEquals(false, BooleanUtils.toBoolean("no"));
    assertEquals(false, BooleanUtils.toBoolean("off"));
    assertEquals(false, BooleanUtils.toBoolean("yoo"));
  }
예제 #12
0
 @Test(expected = IllegalArgumentException.class)
 public void test_toBoolean_Integer_Integer_Integer_noMatch() {
   BooleanUtils.toBoolean(Integer.valueOf(8), Integer.valueOf(6), Integer.valueOf(7));
 }
예제 #13
0
 @Test(expected = IllegalArgumentException.class)
 public void test_toBoolean_int_int_int_noMatch() {
   BooleanUtils.toBoolean(8, 6, 7);
 }
예제 #14
0
 // -----------------------------------------------------------------------
 @Test
 public void test_toBoolean_int_int_int() {
   assertEquals(true, BooleanUtils.toBoolean(6, 6, 7));
   assertEquals(false, BooleanUtils.toBoolean(7, 6, 7));
 }