Describe the bug
I catched a bug in my code by some test, but the error message was a little misleading:
FAILED:
[ctest] CHECK_THAT( some_uint8_t, WithinAbs(5.5, 0.5) )
[ctest] with expansion:
[ctest] '2' is within 0.5 of 5.5
I wondered, where the 2 could have possibly come from, until I ran the test in the VSCode debugger, which automatically prints next to each uint8_t variable its numeric value and it's ascii character.
'2' is a character, but we're doing a number comparison, so printing a character is only misleading.
Expected behavior
FAILED:
[ctest] CHECK_THAT( some_uint8_t, WithinAbs(5.5, 0.5) )
[ctest] with expansion:
[ctest] 50 is within 0.5 of 5.5
Reproduction steps
Something like
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
TEST("misleading error message", "") {
uint8_t var = 50;
CHECK_THAT( var, WithinAbs(5.5, 0.5) );
}
Platform information:
- OS: ubuntu 24.04
- Compiler+version: gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
- Catch version: Catch2 v3.4.0
Describe the bug
I catched a bug in my code by some test, but the error message was a little misleading:
I wondered, where the 2 could have possibly come from, until I ran the test in the VSCode debugger, which automatically prints next to each uint8_t variable its numeric value and it's ascii character.
'2' is a character, but we're doing a number comparison, so printing a character is only misleading.
Expected behavior
Reproduction steps
Something like
Platform information: