< prev index next >

test/lib/jdk/test/lib/Asserts.java

Print this page
rev 51789 : [mq]: asserts


  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package jdk.test.lib;
  25 
  26 import java.util.Objects;
  27 
  28 /**
  29  * Asserts that can be used for verifying assumptions in tests.
  30  *
  31  * An assertion will throw a {@link RuntimeException} if the assertion isn't true.
  32  * All the asserts can be imported into a test by using a static import:
  33  *
  34  * <pre>
  35  * {@code
  36  * import static jdk.testlibrary.Asserts.*;
  37  * }
  38  *
  39  * Always provide a message describing the assumption if the line number of the
  40  * failing assertion isn't enough to understand why the assumption failed. For
  41  * example, if the assertion is in a loop or in a method that is called
  42  * multiple times, then the line number won't provide enough context to
  43  * understand the failure.
  44  * </pre>
  45  */
  46 public class Asserts {
  47 
  48     /**
  49      * Shorthand for {@link #assertLessThan(Comparable, Comparable)}.
  50      *
  51      * @param <T> a type
  52      * @param lhs The left hand side of the comparison.
  53      * @param rhs The right hand side of the comparison.
  54      * @see #assertLessThan(Comparable, Comparable)
  55      */
  56     public static <T extends Comparable<T>> void assertLT(T lhs, T rhs) {




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package jdk.test.lib;
  25 
  26 import java.util.Objects;
  27 
  28 /**
  29  * Asserts that can be used for verifying assumptions in tests.
  30  *
  31  * An assertion will throw a {@link RuntimeException} if the assertion isn't true.
  32  * All the asserts can be imported into a test by using a static import:
  33  *
  34  * <pre>
  35  * {@code
  36  * import static jdk.test.lib.Asserts.*;
  37  * }
  38  *
  39  * Always provide a message describing the assumption if the line number of the
  40  * failing assertion isn't enough to understand why the assumption failed. For
  41  * example, if the assertion is in a loop or in a method that is called
  42  * multiple times, then the line number won't provide enough context to
  43  * understand the failure.
  44  * </pre>
  45  */
  46 public class Asserts {
  47 
  48     /**
  49      * Shorthand for {@link #assertLessThan(Comparable, Comparable)}.
  50      *
  51      * @param <T> a type
  52      * @param lhs The left hand side of the comparison.
  53      * @param rhs The right hand side of the comparison.
  54      * @see #assertLessThan(Comparable, Comparable)
  55      */
  56     public static <T extends Comparable<T>> void assertLT(T lhs, T rhs) {


< prev index next >