[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unit-Test fails


On 1/28/25 1:11 PM, Claus Dietrich wrote:
I prepared a unit-test for a Julian Day algorithm, where I compare the result with a reference value out of a book:
Assert.Equals(JulianDay(Date(-1001, 8, 17, 21, 36, 0), 0), 1355671.4, "JD to be 1355671.4 on the 17.08.-1001 21:36:00 UTC")
The test fails with following output in the IDE-console:

not ok 14 - TestExamples.HJulianDate.121: JD to be 1355671.4 on the 17.08.-1001 21:36:00 UTC
   #
   # ------------- Expected -------------
   # 1355671.4
   #
   # ---------------- Got ---------------
   # 1355671.4
   # ------------------------------------
   #

Why is that? How can an Equals-test fail, when the displayed comparison values are obviously equal?

13 other unit tests of the same kind are OK.
Best regards
Claus

It must be in the way that floating point numbers are handled. The following also reports "ok":
' Gambas module file


Public Sub Main()

  Assert.Equals(1355671.4000000005, 1355671.4, "Yes?")

End


--
Lee

--- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
--- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----


Follow-Ups:
Re: Unit-Test failsChristof Thalhofer <chrisml@xxxxxxxxxxx>
References:
Unit-Test failsClaus Dietrich <claus.dietrich@xxxxxxxxxx>