@Test public final void testTotalIterableOfLong() { final Iterable<Long> numbers1 = asList(convertToBoxed(NUMBERS1)); final Iterable<Long> numbers2 = asList(convertToBoxed(NUMBERS2)); long total1 = 0; for (final Long n : numbers1) total1 += n.longValue(); long total2 = 0; for (final Long n : numbers2) total2 += n.longValue(); final long expected1 = total1; final long actual1 = total(numbers1); // System.out.println("expected: " + expected1 + "\nactual: " + actual1); assertTrue(expected1 == actual1); final long expected2 = total2; final long actual2 = total(numbers2); // System.out.println("expected: " + expected2 + "\nactual: " + actual2); assertTrue(expected2 == actual2); final Iterable<Long> numbers3 = asList(convertToBoxed(NUMBERS3)); final Iterable<Long> numbers4 = asList(convertToBoxed(NUMBERS4)); long total3 = 0; for (final Long n : numbers3) total3 += n.longValue(); long total4 = 0; for (final Long n : numbers4) total4 += n.longValue(); final long expected3 = total3; final long actual3 = total(numbers3); // System.out.println("expected: " + expected3 + "\nactual: " + actual3); assertTrue(expected3 == actual3); final long expected4 = total4; final long actual4 = total(numbers4); // System.out.println("expected: " + expected4 + "\nactual: " + actual4); assertTrue(expected4 == actual4); }
@Test public final void testTotalBoxedLongBoxedLongBoxedLongBoxedLongBoxedLongBoxedLongArray() { final Long[] numbers1 = convertToBoxed(NUMBERS1); final Long[] numbers2 = convertToBoxed(NUMBERS2); for (final Long n1 : numbers1) { for (final Long n2 : numbers2) { for (final Long n3 : numbers1) { for (final Long n4 : numbers2) { for (final Long n5 : numbers1) { @SuppressWarnings("boxing") long total1 = n1 + n2 + n3 + n4 + n5; for (final Long n : numbers1) total1 += n.longValue(); @SuppressWarnings("boxing") final Long expected1 = total1; @SuppressWarnings("boxing") final Long actual1 = total(n1, n2, n3, n4, n5, numbers1); // System.out.println("expected: " + expected1 + "\nactual: " + actual1); assertThat(actual1, is(equalTo(expected1))); @SuppressWarnings("boxing") long total2 = n1 + n2 + n3 + n4 + n5; for (final Long n : numbers2) total2 += n.longValue(); @SuppressWarnings("boxing") final Long expected2 = total2; @SuppressWarnings("boxing") final Long actual2 = total(n1, n2, n3, n4, n5, numbers2); // System.out.println("expected: " + expected2 + "\nactual: " + actual2); assertThat(actual2, is(equalTo(expected2))); } } } } } final Long[] numbers3 = new Long[NUMBERS3.length]; System.arraycopy(convertToBoxed(NUMBERS3), 0, numbers3, 0, NUMBERS3.length); final Long[] numbers4 = new Long[NUMBERS4.length]; System.arraycopy(convertToBoxed(NUMBERS4), 0, numbers4, 0, NUMBERS4.length); for (final Long n1 : numbers3) { for (final Long n2 : numbers4) { for (final Long n3 : numbers3) { for (final Long n4 : numbers4) { for (final Long n5 : numbers3) { @SuppressWarnings("boxing") long total3 = n1 + n2 + n3 + n4 + n5; for (final Long n : numbers3) total3 += n.longValue(); @SuppressWarnings("boxing") final Long expected3 = total3; @SuppressWarnings("boxing") final Long actual3 = total(n1, n2, n3, n4, n5, numbers3); // System.out.println("expected: " + expected3 + "\nactual: " + actual3); assertThat(actual3, is(equalTo(expected3))); @SuppressWarnings("boxing") long total4 = n1 + n2 + n3 + n4 + n5; for (final Long n : numbers4) total4 += n.longValue(); @SuppressWarnings("boxing") final Long expected4 = total4; @SuppressWarnings("boxing") final Long actual4 = total(n1, n2, n3, n4, n5, numbers4); // System.out.println("expected: " + expected4 + "\nactual: " + actual4); assertThat(actual4, is(equalTo(expected4))); } } } } } }