JuliaTesting / ReferenceTests.jl

Utility package for comparing data against reference files
https://juliatesting.github.io/ReferenceTests.jl/latest/
Other
82 stars 14 forks source link

Is it possible to add a Number/Real only test case with tolerance argument? #25

Closed johnnychen94 closed 4 years ago

johnnychen94 commented 5 years ago

I tried to use ReferenceTests in the recent development of ImageDistances.jl, but it would directly throw errors even if there's an insignificant numerical difference

Test for "CIEDE2000_Color1.txt" failed.
DIFF ------------------------
-"900.000068665732"
+"900.000063800018"

which is just caused by Float32 <--> Float64 accuracy issue

I can try to work on it if it’s possible( without much efforts)

Evizero commented 5 years ago

Mhm yea I see. I didn't consider testing floating point numbers yet. Since this is basically a text comparision any diff would trigger a failed test

oxinabox commented 5 years ago

I think the way to do this would be to add a handler. https://github.com/Evizero/ReferenceTests.jl/blob/master/src/handlers.jl

Which would if one side is txt call parse on it. Some extra machiney might have to be added if the format can not be expressed via the file extension. Possibly the format could be expressed via the .jl extension, and Meta.parse could be used?