Skip to content

Commit 5c972e8

Browse files
author
Glen K. Peterson
committed
Converted another unit test from ScalTest to JUnit and fixed copyright profile.
1 parent e63157d commit 5c972e8

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

.idea/copyright/GlenPBApache.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright (c) 2014-03-07 PlanBase Inc. & Glen Peterson
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
package org.organicdesign.fp.ephemeral;
15+
16+
import org.junit.Test;
17+
import org.junit.runner.RunWith;
18+
import org.junit.runners.JUnit4;
19+
20+
import static org.junit.Assert.assertArrayEquals;
21+
22+
@RunWith(JUnit4.class)
23+
public class ViewDroppedTest {
24+
25+
@Test
26+
public void singleDrops() {
27+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(0).toJavaArrayList().toArray(),
28+
new Integer[] {1,2,3,4,5,6,7,8,9});
29+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(1).toJavaArrayList().toArray(),
30+
new Integer[] {2,3,4,5,6,7,8,9});
31+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(2).toJavaArrayList().toArray(),
32+
new Integer[] {3,4,5,6,7,8,9});
33+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(3).toJavaArrayList().toArray(),
34+
new Integer[] {4, 5, 6, 7, 8, 9});
35+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(8).toJavaArrayList().toArray(),
36+
new Integer[] {9});
37+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(9).toJavaArrayList().toArray(),
38+
new Integer[] {});
39+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(10).toJavaArrayList().toArray(),
40+
new Integer[] {});
41+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(10000).toJavaArrayList().toArray(),
42+
new Integer[] {});
43+
}
44+
45+
@Test(expected = IllegalArgumentException.class)
46+
public void exception1() {
47+
ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(-1);
48+
}
49+
@Test(expected = IllegalArgumentException.class)
50+
public void exception2() {
51+
ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(-99);
52+
}
53+
54+
@Test
55+
public void multiDrops() {
56+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(1).drop(1).toJavaArrayList().toArray(),
57+
new Integer[] {3,4,5,6,7,8,9});
58+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9).drop(1).drop(1).drop(1).toJavaArrayList().toArray(),
59+
new Integer[] {4,5,6,7,8,9});
60+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9)
61+
.drop(1).drop(1).drop(1).drop(1).drop(1)
62+
.drop(1).drop(1).drop(1).toJavaArrayList().toArray(),
63+
new Integer[] {9});
64+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9)
65+
.drop(1).drop(1).drop(1).drop(1).drop(1)
66+
.drop(1).drop(1).drop(1).drop(1).toJavaArrayList().toArray(),
67+
new Integer[] {});
68+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9)
69+
.drop(1).drop(1).drop(1).drop(1).drop(1)
70+
.drop(1).drop(1).drop(1).drop(1).drop(1).toJavaArrayList().toArray(),
71+
new Integer[] {});
72+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9)
73+
.drop(1).drop(1).drop(1).drop(1).drop(1)
74+
.drop(1).drop(1).drop(1).drop(1).drop(1)
75+
.drop(1).drop(1).drop(1).drop(1).drop(1).toJavaArrayList().toArray(),
76+
new Integer[] {});
77+
78+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9)
79+
.drop(0).drop(1).drop(2).drop(3).toJavaArrayList().toArray(),
80+
new Integer[] {7,8,9});
81+
assertArrayEquals(ViewFromArray.of(1,2,3,4,5,6,7,8,9)
82+
.drop(3).drop(2).drop(1).drop(0).toJavaArrayList().toArray(),
83+
new Integer[] {7,8,9});
84+
}
85+
}

0 commit comments

Comments
 (0)