Skip to content

Instantly share code, notes, and snippets.

@kenparker
Created July 17, 2019 12:38
Show Gist options
  • Save kenparker/7356cb74382762eb881cfcbdb098a8b3 to your computer and use it in GitHub Desktop.
Save kenparker/7356cb74382762eb881cfcbdb098a8b3 to your computer and use it in GitHub Desktop.
public class VectorCreationMethodsTest {
private String a = "Angel";
private String b = "Berta";
@Test
public void vectorEmpty_Then_AnEmptyVectorIsCreated() {
Vector<String> vector = Vector.empty();
assertThat(vector.size()).isEqualTo(0);
}
@Test
public void vectorOf_When_SomeElementsAreProvided_Then_AVectorWithTheElementsIsCreated() {
Vector<String> of = Vector.of(a, b);
assertThat(of).hasSize(2).containsOnly(a, b);
}
@Test
public void vectorFill_When_ObjectAndAMaxNumberIsProvided_Then_AVectorWithNumberOfObjectsIsCreated() {
Vector<String> fill = Vector.fill(a, 5);
assertThat(fill).hasSize(5).containsOnly(a);
}
@Test
public void vectorGenerate_When_SupplierAndAMaxNumberIsProvided_Then_AVectorWithNumberOfSupplierResultsIsCreated() {
Supplier<Employee> supplier = Employee::new;
Vector<Employee> generate = Vector.generate(supplier, 5);
assertThat(generate).hasSize(5).hasOnlyElementsOfType(Employee.class);
}
@Test
public void vectorRange_When_RangeIntegerValuesAreProvided_Then_AVectorWithIntegersInTheRangeIsCreated() {
Vector<Integer> range = Vector.range(1, 5);
assertThat(range).hasSize(4).containsOnly(1, 2, 3, 4);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment