Closed FRosner closed 10 years ago
@FRosner I came across the fact that StatisticsUtil.sum(...)
does not check for an overflow while adding up the elements. Do you think there is no case where the collection elements can produce an overflow?
@Husterknupp what do you mean by an overflow? Summing MAX_INT and 1? What should happen then? I guess MAX_INT would be the right result. You can easily add a test for each number type that has a maximum value, right?
E.g. assertThat(StatisticsUtil.sum(Lists.newArrayList(Integer.MAX_VALUE, 1))).isEqualTo(Integer.MAX_VALUE)
The class
StatisticsUtil
has no unit tests. The sum method needs to be tested.