Пример #1
0
 public final boolean assertInstanceOf(String $label, Class<?> $klass, Object $obj) {
   if ($obj == null) {
     $unitFailures++;
     $log.warn(
         messageFail(
             $label, "null is never an instance of anything, and certainly not " + $klass + "."),
         new AssertionFailed());
     return false;
   }
   try {
     $klass.cast($obj);
     $log.debug(
         messagePass(
             $label,
             "\""
                 + $obj.getClass().getCanonicalName()
                 + "\" is an instance of \""
                 + $klass.getCanonicalName()
                 + "\""));
     return true;
   } catch (ClassCastException $e) {
     $unitFailures++;
     $log.warn(messageFail($label, $e.getMessage() + "."), new AssertionFailed());
     return false;
   }
 }
Пример #2
0
 public final boolean assertEquals(String $label, float $expected, float $actual) {
   if ($expected != $actual) {
     $unitFailures++;
     $log.warn(messageFail($label, $expected, $actual), new AssertionFailed());
     return false;
   }
   $log.debug(messagePass($label, $expected, $actual));
   return true;
 }
Пример #3
0
 public final boolean assertEquals(String $label, long $expected, long $actual, long $margin) {
   if (Math.abs($expected - $actual) <= $margin) {
     $unitFailures++;
     $log.warn(messageFail($label, $expected, $actual, $margin), new AssertionFailed());
     return false;
   }
   $log.debug(messagePass($label, $expected, $actual, $margin));
   return true;
 }
Пример #4
0
 public final boolean assertNotSame(String $label, Object $expected, Object $actual) {
   if ($expected == $actual) {
     $unitFailures++;
     $log.warn(messageFailNot($label, $expected, $actual), new AssertionFailed());
     return false;
   }
   $log.debug(messagePassNot($label, $expected, $actual));
   return true;
 }