Class Assert


  • public class Assert
    extends java.lang.Object
    A utility for making programming assertions.
    Version:
    1.7
    • Constructor Summary

      Constructors 
      Constructor Description
      Assert()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void equals​(java.lang.Object expectedValue, java.lang.Object actualValue)
      Throws an AssertionFailedException if the given objects are not equal, according to the equals method.
      static void equals​(java.lang.Object expectedValue, java.lang.Object actualValue, java.lang.String message)
      Throws an AssertionFailedException with the given message if the given objects are not equal, according to the equals method.
      static void isTrue​(boolean assertion)
      Throws an AssertionFailedException if the given assertion is not true.
      static void isTrue​(boolean assertion, java.lang.String message)
      Throws an AssertionFailedException with the given message if the given assertion is not true.
      static void shouldNeverReachHere()
      Always throws an AssertionFailedException.
      static void shouldNeverReachHere​(java.lang.String message)
      Always throws an AssertionFailedException with the given message.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Assert

        public Assert()
    • Method Detail

      • isTrue

        public static void isTrue​(boolean assertion)
        Throws an AssertionFailedException if the given assertion is not true.
        Parameters:
        assertion - a condition that is supposed to be true
        Throws:
        AssertionFailedException - if the condition is false
      • isTrue

        public static void isTrue​(boolean assertion,
                                  java.lang.String message)
        Throws an AssertionFailedException with the given message if the given assertion is not true.
        Parameters:
        assertion - a condition that is supposed to be true
        message - a description of the assertion
        Throws:
        AssertionFailedException - if the condition is false
      • equals

        public static void equals​(java.lang.Object expectedValue,
                                  java.lang.Object actualValue)
        Throws an AssertionFailedException if the given objects are not equal, according to the equals method.
        Parameters:
        expectedValue - the correct value
        actualValue - the value being checked
        Throws:
        AssertionFailedException - if the two objects are not equal
      • equals

        public static void equals​(java.lang.Object expectedValue,
                                  java.lang.Object actualValue,
                                  java.lang.String message)
        Throws an AssertionFailedException with the given message if the given objects are not equal, according to the equals method.
        Parameters:
        expectedValue - the correct value
        actualValue - the value being checked
        message - a description of the assertion
        Throws:
        AssertionFailedException - if the two objects are not equal
      • shouldNeverReachHere

        public static void shouldNeverReachHere()
        Always throws an AssertionFailedException.
        Throws:
        AssertionFailedException - thrown always
      • shouldNeverReachHere

        public static void shouldNeverReachHere​(java.lang.String message)
        Always throws an AssertionFailedException with the given message.
        Parameters:
        message - a description of the assertion
        Throws:
        AssertionFailedException - thrown always