1 package io.atlassian.fugue;
2
3 import org.junit.Test;
4
5 import java.util.Arrays;
6 import java.util.Collections;
7
8 import static io.atlassian.fugue.Iterables.concat;
9 import static org.hamcrest.MatcherAssert.assertThat;
10 import static org.hamcrest.Matchers.contains;
11 import static org.hamcrest.Matchers.emptyIterable;
12 import static org.hamcrest.core.Is.is;
13
14 public class IterablesConcatTest {
15
16 @Test public void concatTwo() {
17 assertThat(concat(Arrays.asList(1, 2), Arrays.asList(3, 4)), contains(1, 2, 3, 4));
18 }
19
20 @Test public void concatOne() {
21 assertThat(concat(Arrays.asList(1, 2)), contains(1, 2));
22 }
23
24 @Test public void concatOneEmpty() {
25 assertThat(concat(Arrays.asList(1, 2), Collections.emptyList()), contains(1, 2));
26 }
27
28 @Test public void concatEmptyWithOne() {
29 assertThat(concat(Collections.emptyList(), Arrays.asList(1, 2)), contains(1, 2));
30 }
31
32 @Test public void concatEmpty() {
33 assertThat(concat(Collections.emptyList(), Collections.emptyList()), emptyIterable());
34 }
35
36 @Test public void concatNothing() {
37 assertThat(concat(), emptyIterable());
38 }
39
40 @Test(expected = NullPointerException.class) public void concatNullEmpty() {
41 assertThat(concat(null, Collections.emptyList()), emptyIterable());
42 }
43
44 @Test(expected = NullPointerException.class) public void concatEmptyNull() {
45 assertThat(concat(Collections.emptyList(), null), emptyIterable());
46 }
47
48 @Test public void concatToString() {
49 assertThat(concat(Arrays.asList(1, 2)).toString(), is("[1, 2]"));
50 }
51
52 }