Last active
April 3, 2019 10:36
-
-
Save kenparker/00bbe4274846bac0dcc0e1d8393e2877 to your computer and use it in GitHub Desktop.
Cyclops VectorDemoTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VectorDemoTest { | |
private String a = "Angel"; | |
private String b = "Marc"; | |
private String c = "Lucy"; | |
private String d = "Bert"; | |
@Test | |
public void givenSomeStrings_WhenVectorOf_ThenVectorIsCreated() { | |
Vector<String> vector = Vector.of(a, b, c); | |
assertThat(vector).isInstanceOf(Vector.class); | |
assertThat(vector).contains(a, b, c); | |
} | |
@Test | |
public void givenAVector_WhenAStringIsAppended_ThenVectorIsImmutable() { | |
Vector<String> vector = Vector.of(a,b); | |
vector.append(c); | |
assertThat(vector).doesNotContain(c); | |
} | |
@Test | |
public void givenAJava8List_whenAStringIsAdded_ThenListIsMutable() { | |
List<String> list = new ArrayList<>(); | |
list.add(a); | |
list.add(b); | |
list.add(c); | |
assertThat(list).contains(c); | |
} | |
@Test | |
public void givenAStringAndAVector_WhenVectorAppend_ThenStringIsAddedToVectorAndNewVectorIsCreated() { | |
Vector<String> vector = Vector.of(a, b, c); | |
Vector<String> appendVector = vector.append(d); | |
assertThat(appendVector).contains(a,b,c,d); | |
assertThat(appendVector).isNotSameAs(vector); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment