Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8064953

Asserts.assert* should print values

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • b43

        assert methods which get message as a parameter should print "compared" values anyway

        suggested fix:
        diff -r 3d018f7c144e test/testlibrary/com/oracle/java/testlibrary/Asserts.java
        --- a/test/testlibrary/com/oracle/java/testlibrary/Asserts.java Fri Nov 14 16:55:27 2014 +0300
        +++ b/test/testlibrary/com/oracle/java/testlibrary/Asserts.java Sat Nov 15 00:35:05 2014 +0300
        @@ -234,8 +234,7 @@
              * @see #assertGreaterThan(T, T, String)
              */
             public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs) {
        - String msg = "Expected that " + format(lhs) + " > " + format(rhs);
        - assertGreaterThan(lhs, rhs, msg);
        + assertGreaterThan(lhs, rhs, null);
             }
         
             /**
        @@ -247,7 +246,7 @@
              * @throws RuntimeException if the assertion isn't valid.
              */
             public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs, String msg) {
        - assertTrue(compare(lhs, rhs, msg) > 0, msg);
        + assertTrue(compare(lhs, rhs, msg) > 0, (msg == null ? "Expected that " : msg) + " " + format(lhs) + " > " + format(rhs));
             }

              tpivovarova Tatiana Pivovarova (Inactive)
              iignatyev Igor Ignatyev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: