Advertisement
JeffGrigg

PascalVectorTest

Nov 7th, 2018
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.22 KB | None | 0 0
  1. import junit.framework.TestCase;
  2.  
  3. import java.util.Arrays;
  4. import java.util.List;
  5. import java.util.stream.Collectors;
  6.  
  7. public class PascalVectorTest extends TestCase {
  8.  
  9.     public void test0() {
  10.         assertArraysEquals(new int[] {1}, PascalVectorSolution.pascalVector(0));
  11.     }
  12.  
  13.     public void test1() {
  14.         assertArraysEquals(new int[] {1, 1}, PascalVectorSolution.pascalVector(1));
  15.     }
  16.  
  17.     public void test2() {
  18.         assertArraysEquals(new int[] {1, 2, 1}, PascalVectorSolution.pascalVector(2));
  19.     }
  20.  
  21.     public void test3() {
  22.         assertArraysEquals(new int[] {1, 3, 3, 1}, PascalVectorSolution.pascalVector(3));
  23.     }
  24.  
  25.     public void test4() {
  26.         assertArraysEquals(new int[] {1, 4, 6, 4, 1}, PascalVectorSolution.pascalVector(4));
  27.     }
  28.  
  29.     private void assertArraysEquals(final int[] expectedPascalVectorValues, final int[] actualPascalVectorValues) {
  30.         final List<Integer> expectedValuesAsList = Arrays.stream(expectedPascalVectorValues).boxed().collect(Collectors.toList());
  31.         final List<Integer> actualValuesAsList = Arrays.stream(actualPascalVectorValues).boxed().collect(Collectors.toList());
  32.         assertEquals(expectedValuesAsList, actualValuesAsList);
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement