|
1 | 1 | /* |
2 | | - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
98 | 98 | import java.lang.reflect.Method; |
99 | 99 |
|
100 | 100 | import java9.lang.Integers; |
| 101 | +import java9.util.J8Arrays; |
101 | 102 | import java9.util.Lists; |
102 | 103 | import java9.util.Maps; |
103 | 104 | import java9.util.Objects; |
@@ -339,6 +340,7 @@ private static <T> void testEmptyCollection(Collection<T> c) { |
339 | 340 | equal(c.toString(),"[]"); |
340 | 341 | equal(c.toArray().length, 0); |
341 | 342 | equal(c.toArray(new Object[0]).length, 0); |
| 343 | + equal(J8Arrays.toArray((Collection<Object>) c, Object[]::new).length, 0); |
342 | 344 | check(c.toArray(new Object[]{42})[0] == null); |
343 | 345 |
|
344 | 346 | Object[] a = new Object[1]; a[0] = Boolean.TRUE; |
@@ -616,6 +618,13 @@ private static void checkFunctionalInvariants(Collection<Integer> c) { |
616 | 618 | check(a.getClass() == Integer[].class); |
617 | 619 | } |
618 | 620 |
|
| 621 | + { |
| 622 | + Integer[] a = J8Arrays.toArray(c, Integer[]::new); |
| 623 | + equal(c.size(), a.length); |
| 624 | + check(a.getClass() == Integer[].class); |
| 625 | + check(Arrays.equals(c.toArray(new Integer[0]), a)); |
| 626 | + } |
| 627 | + |
619 | 628 | check(c.equals(c)); |
620 | 629 | if (c instanceof Serializable) { |
621 | 630 | //System.out.printf("Serializing %s%n", c.getClass().getName()); |
|
0 commit comments