SumLists { public int sumReverse(ListNode<Integer> n1, ListNode<Integer> n2) { validateInput(n1, n2); int n1Value = calculateReverseNumber(n1); int n2Value = calculateReverseNumber(n2); return n1Value + n2Value; }  int sumReverse(ListNode<Integer> n1, ListNode<Integer> n2); int sum(ListNode<Integer> n1, ListNode<Integer> n2);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullListAsFirstParameterReverse() { sumLists.sumReverse(null, new ListNode<Integer>(0)); }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullListAsSecondParameterReverse() { sumLists.sumReverse(new ListNode<Integer>(0), null); }
@Test public void shouldSumNumbersWithJustOneDigitReverse() { ListNode<Integer> n1 = createList(new int[] { 3 }); ListNode<Integer> n2 = createList(new int[] { 8 }); int result = sumLists.sumReverse(n1, n2); assertEquals(11, result); }
@Test public void shouldSumNumbersWithMoreThanOneDigitReverse() { ListNode<Integer> n1 = createList(new int[] { 5, 5, 1 }); ListNode<Integer> n2 = createList(new int[] { 4, 1, 3 }); int result = sumLists.sumReverse(n1, n2); assertEquals(469, result); }
@Test public void shouldSumNumbersWithDifferentSizesReverse() { ListNode<Integer> n1 = createList(new int[] { 5, 5, 1 }); ListNode<Integer> n2 = createList(new int[] { 5 }); int result = sumLists.sumReverse(n1, n2); assertEquals(160, result); }