< prev index next > test/jdk/java/util/Arrays/AsList.java
Print this page
/*
* @test
* @bug 8155600
* @summary Tests for Arrays.asList()
+ * @library /test/lib
* @run junit AsList
*/
+ import java.time.LocalDate;
import java.util.Arrays;
import java.util.Iterator;
import java.util.NoSuchElementException;
+ import java.util.Optional;
import java.util.stream.IntStream;
+ import jdk.test.lib.valueclass.AsValueClass;
+
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import static org.junit.jupiter.api.Assertions.*;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class AsList {
+
+ @AsValueClass
+ record V(int x) {}
+
/*
* Iterator contract test
*/
@ParameterizedTest
@MethodSource("arrays")
{ new Object[] { 1, null, 2 } },
{ new Object[] { 1, 2, null } },
{ new Object[] { null, null, null } },
{ new Object[] { 1, 2, 3, null, 4 } },
{ new Object[] { "a", "a", "a", "a" } },
- { IntStream.range(0, 100).boxed().toArray() }
+ { IntStream.range(0, 100).boxed().toArray() },
+ { new Object[] { new V(1), new V(2), null, new V(3) } },
+ { new Object[] { Integer.valueOf(1), Integer.valueOf(2), null, Integer.valueOf(3) } },
+ { new Object[] { LocalDate.of(2000, 1, 1), LocalDate.of(2000, 12, 31), LocalDate.now() } },
+ { new Object[] { Optional.of(1), Optional.empty(), Optional.of("a") } },
+ { new Object[] { Boolean.TRUE, Boolean.FALSE, null } }
};
}
}
< prev index next >