author | pli |
Tue, 16 Jul 2019 00:57:00 +0000 | |
changeset 55689 | 8c5c9d86e1d6 |
parent 48519 | 482ede6c4936 |
permissions | -rw-r--r-- |
23572
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
1 |
/* |
45006
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
2 |
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
23572
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
4 |
* |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
8 |
* |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
13 |
* accompanied this code). |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
14 |
* |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
18 |
* |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
21 |
* questions. |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
22 |
*/ |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
23 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
24 |
/** |
48519
482ede6c4936
8194959: Correct test tag to move bugid from @test to @bug
amlu
parents:
47216
diff
changeset
|
25 |
* @test |
482ede6c4936
8194959: Correct test tag to move bugid from @test to @bug
amlu
parents:
47216
diff
changeset
|
26 |
* @bug 8037857 |
23572
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
27 |
* @summary tests for stream and spliterator factory methods |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
28 |
* @run testng StreamAndSpliterator |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
29 |
*/ |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
30 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
31 |
import org.testng.annotations.Test; |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
32 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
33 |
import java.util.Arrays; |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
34 |
import java.util.Spliterators; |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
35 |
|
45006
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
36 |
import org.testng.Assert.ThrowingRunnable; |
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
37 |
|
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
38 |
import static org.testng.Assert.assertThrows; |
23572
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
39 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
40 |
public class StreamAndSpliterator { |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
41 |
@Test |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
42 |
public void testStreamNPEs() { |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
43 |
assertThrowsNPE(() -> Arrays.stream((int[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
44 |
assertThrowsNPE(() -> Arrays.stream((long[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
45 |
assertThrowsNPE(() -> Arrays.stream((double[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
46 |
assertThrowsNPE(() -> Arrays.stream((String[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
47 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
48 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
49 |
@Test |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
50 |
public void testStreamAIOBEs() { |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
51 |
// origin > fence |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
52 |
assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
53 |
assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
54 |
assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
55 |
assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
56 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
57 |
// bad origin |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
58 |
assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
59 |
assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
60 |
assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
61 |
assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
62 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
63 |
// bad fence |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
64 |
assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
65 |
assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
66 |
assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
67 |
assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
68 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
69 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
70 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
71 |
@Test |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
72 |
public void testSpliteratorNPEs() { |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
73 |
assertThrowsNPE(() -> Arrays.spliterator((int[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
74 |
assertThrowsNPE(() -> Arrays.spliterator((long[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
75 |
assertThrowsNPE(() -> Arrays.spliterator((double[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
76 |
assertThrowsNPE(() -> Arrays.spliterator((String[]) null, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
77 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
78 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
79 |
@Test |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
80 |
public void testSpliteratorAIOBEs() { |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
81 |
// origin > fence |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
82 |
assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
83 |
assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
84 |
assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
85 |
assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
86 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
87 |
// bad origin |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
88 |
assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
89 |
assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
90 |
assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
91 |
assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, -1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
92 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
93 |
// bad fence |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
94 |
assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
95 |
assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
96 |
assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
97 |
assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 0, 1)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
98 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
99 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
100 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
101 |
@Test |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
102 |
public void testSpliteratorNPEsFromSpliterators() { |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
103 |
assertThrowsNPE(() -> Spliterators.spliterator((int[]) null, 0, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
104 |
assertThrowsNPE(() -> Spliterators.spliterator((long[]) null, 0, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
105 |
assertThrowsNPE(() -> Spliterators.spliterator((double[]) null, 0, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
106 |
assertThrowsNPE(() -> Spliterators.spliterator((String[]) null, 0, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
107 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
108 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
109 |
@Test |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
110 |
public void testSpliteratorAIOBEsFromSpliterators() { |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
111 |
// origin > fence |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
112 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
113 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
114 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
115 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
116 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
117 |
// bad origin |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
118 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, -1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
119 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, -1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
120 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, -1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
121 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, -1, 0, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
122 |
|
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
123 |
// bad fence |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
124 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 0, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
125 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 0, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
126 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 0, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
127 |
assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 0, 1, 0)); |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
128 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
129 |
|
45006
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
130 |
void assertThrowsNPE(ThrowingRunnable r) { |
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
131 |
assertThrows(NullPointerException.class, r); |
23572
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
132 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
133 |
|
45006
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
134 |
void assertThrowsAIOOB(ThrowingRunnable r) { |
1c15ce5f636c
8023897: Replace/update/rename executeAndCatch in various tests to assertThrows
amlu
parents:
23572
diff
changeset
|
135 |
assertThrows(ArrayIndexOutOfBoundsException.class, r); |
23572
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
136 |
} |
0b4b0e183619
8037857: Methods j.u.Arrays.spliterator/stream(X[], int, int) throw IAE instead of specified AIOOBE when endIndex < startIndex
psandoz
parents:
diff
changeset
|
137 |
} |