Closed mschmitz2 closed 3 months ago
Guess I forgot to check some of the other unit tests. It seems like, although the results of a division of BaseUnit / BaseUnit
is UnknownUnit
, the examples in the failing tests default to using the new Average(Temperature)
methods instead of the original Average(UnknownUnit)
methods... Not sure why this would be the case.
Great job spotting the bugs! Maybe we should make it a rule always to make a test for every new feature that also include temperature in degree - cause that is where most of the bugs is :-)
The issue comes from
Sum()
, which only makes sense for absolute temperature (Kelvin).The added
Average()
methods also work for relative temperatures, e.g. °C.Maybe there is a "cleaner" fix for this... like replacing the current
return list.Sum() / list.Count();
in the genericAverage
method by something that does the right thing in case ofTemperature
.