Reporting of Test

Aperta
#3,080 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@mr3screen ci sta già lavorando.

Dal 17/3/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
cpp
Ambito
testing-qa

Direzione di ricerca

Riproduci il problema con il TEST mostrato, il valore uint8_t, CHECK_THAT e il matcher WithinAbs, quindi segui il percorso di reporting di Catch2 per il valore espanso. Aggiungi una copertura di regressione per l'output numerico e verifica il risultato tramite il report di errore di ctest.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
C++
Stelle
21.6k
Fork
3.4k
Merge medio
3g 12h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di catchorg/Catch2

Tutte le issue di catchorg/Catch2

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.