< prev index next >

test/jdk/java/time/test/java/time/temporal/TestDateTimeValueRange.java

Print this page
rev 58118 : 8239520: ValueRange.of(long, long, long) does not throw IAE on invalid inputs
Reviewed-by: rriggs

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -73,10 +73,11 @@
 import org.testng.annotations.Test;
 import test.java.time.AbstractTest;
 
 /**
  * Test.
+ * @bug 8239520
  */
 @Test
 public class TestDateTimeValueRange extends AbstractTest {
 
     //-----------------------------------------------------------------------

@@ -136,10 +137,15 @@
     @Test(expectedExceptions = IllegalArgumentException.class)
     public void test_of_longlonglong_smallestmaxminGtMax() {
         ValueRange.of(1, 31, 28);
     }
 
+    @Test(expectedExceptions = IllegalArgumentException.class)
+    public void test_of_longlonglong_minGtSmallestMax() {
+        ValueRange.of(5, 2, 10);
+    }
+
     //-----------------------------------------------------------------------
     // of(long,long,long,long)
     //-----------------------------------------------------------------------
     @DataProvider(name="valid")
     Object[][] data_valid() {

@@ -176,10 +182,15 @@
                 {31, 2, 3, 28},
 
                 {2, 1, 28, 31},
                 {2, 1, 31, 28},
                 {12, 13, 1, 2},
+
+                {10, 11, 0, 12}, // smallest minimum is greater than the smallest maximum
+                {0, 1, 11, 10}, // smallest maximum is greater than the largest maximum
+                {0, 11, 1, 10}, // largest minimum is greater than the largest maximum
+                {1, 0, 10, 11}, // smallest minimum is greater than the largest minimum
         };
     }
 
     @Test(dataProvider="invalid", expectedExceptions=IllegalArgumentException.class)
     public void test_of_longlonglonglong_invalid(long sMin, long lMin, long sMax, long lMax) {
< prev index next >