rapidfuzz / rapidfuzz-cpp

Rapid fuzzy string matching in C++ using the Levenshtein Distance
https://rapidfuzz.github.io/rapidfuzz-cpp
MIT License
238 stars 37 forks source link

Test failures on i686 #100

Closed mgorny closed 1 year ago

mgorny commented 1 year ago

I've gotten a report that rapidfuzz-cpp-1.10.4's tests are failing on i686.

The specific test failure is:

 1/10 Test  #1: fuzz .............................***Failed    0.05 sec

Test log: LastTest.log Build log: rapidfuzz-cpp-1.10.4_20230108-074550.log

If I'm reading the test output correctly, it seems to be floating-point precision problem, i.e. the test suite assuming bit-exact equality.

maxbachmann commented 1 year ago

Yes in this case the test suite should not compare floating point for exact equality. This is fixed in https://github.com/maxbachmann/rapidfuzz-cpp/commit/91f7d2f88c1e15221de84605df6ae2a1f47f0b8d

juippis commented 1 year ago

Hey,

when patching 1.10.4 with (but no other commits) https://github.com/maxbachmann/rapidfuzz-cpp/commit/91f7d2f88c1e15221de84605df6ae2a1f47f0b8d the tests fail to:

/var/tmp/portage/dev-cpp/rapidfuzz-cpp-1.10.4/work/rapidfuzz-cpp-1.10.4/test/tests-fuzz.cpp:38:      FAILED:
  REQUIRE_THAT( input, Catch::Matchers::WithinAbs(expected, 0.000001) )
with expansion:
  0.0 is within 0.000001 of 80.0
with message:
  score_cutoff does not work correctly for fuzz::ratio

===============================================================================
test cases:   1 |   0 passed | 1 failed
assertions: 241 | 240 passed | 1 failed

<end of output>
Test time =   0.01 sec
----------------------------------------------------------
Test Failed.
"fuzz" end time: Jan 09 06:20 -00
"fuzz" time elapsed: 00:00:00
----------------------------------------------------------

on -march=i686.

maxbachmann commented 1 year ago

Thanks for testing. This seems like another issue with floating point precision. Could you try to apply https://github.com/maxbachmann/rapidfuzz-cpp/commit/d1c917c3990db771cd575433725f22bf8f5867bb as well?

juippis commented 1 year ago

Hey,

with:

all tests pass with -march=i686. Thanks for the swift action here!

>>> Source compiled.
>>> Test phase: dev-cpp/rapidfuzz-cpp-1.10.4
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/dev-cpp/rapidfuzz-cpp-1.10.4/work/rapidfuzz-cpp-1.10.4"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/dev-cpp/rapidfuzz-cpp-1.10.4/work/rapidfuzz-cpp-1.10.4_build"
ctest -j 32 --test-load 999
Test project /var/tmp/portage/dev-cpp/rapidfuzz-cpp-1.10.4/work/rapidfuzz-cpp-1.10.4_build
      Start  1: fuzz
      Start  2: common
      Start  3: Hamming
      Start  4: Indel
      Start  5: LCSseq
      Start  6: Levenshtein
      Start  7: DamerauLevenshtein
      Start  8: OSA
      Start  9: Jaro
      Start 10: JaroWinkler
 1/10 Test  #2: common ...........................   Passed    0.01 sec
 2/10 Test  #3: Hamming ..........................   Passed    0.01 sec
 3/10 Test  #4: Indel ............................   Passed    0.01 sec
 4/10 Test  #5: LCSseq ...........................   Passed    0.01 sec
 5/10 Test  #7: DamerauLevenshtein ...............   Passed    0.00 sec
 6/10 Test  #8: OSA ..............................   Passed    0.00 sec
 7/10 Test  #1: fuzz .............................   Passed    0.01 sec
 8/10 Test  #9: Jaro .............................   Passed    0.02 sec
 9/10 Test #10: JaroWinkler ......................   Passed    0.02 sec
10/10 Test  #6: Levenshtein ......................   Passed    8.88 sec

100% tests passed, 0 tests failed out of 10

Total Test time (real) =   8.88 sec
 * Tests succeeded.
>>> Completed testing dev-cpp/rapidfuzz-cpp-1.10.4
maxbachmann commented 1 year ago

:+1: