catchorg / catchorg/Catch2

Reporting of Test

Open
#3,080 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

**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
#include
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.