FRosner / DataGenerator

Tool for generating various test data for machine learning and data mining algorithms.
Apache License 2.0
10 stars 2 forks source link

Test StatisticsUtil.sum(...) #188

Closed FRosner closed 10 years ago

FRosner commented 10 years ago

The class StatisticsUtil has no unit tests. The sum method needs to be tested.

Husterknupp commented 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?

FRosner commented 10 years ago

@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)