doctest icon indicating copy to clipboard operation
doctest copied to clipboard

No reset to std::dec for printing the test summary table

Open eyalroz opened this issue 5 years ago • 4 comments

I'm using v2.3.0 .

If I set std::hex on cout somewhere in the testcode, doctest does not reset this to std::dec for printing its test summary. I think that it should.

eyalroz avatar Feb 23 '20 00:02 eyalroz

Are you sure that std::dec is enough? I mean, are there no other ios flags you need to make sure and set?

eyalroz avatar Feb 24 '20 17:02 eyalroz

From what I saw I couldn't figure out how to fully reset the ios flags of a stream (maybe I glossed over it). It did feel sloppy... Any idea how? I'd reopen this and properly fix it for the next version.

It's also advisable for people who change these flags to use RAII so that they reset them when the RAII guard goes out of scope...

EDIT: forget about that - I should look into std::resetiosflags(). I could also save the flags of std::cout at the beginning of the test run and later use that

onqtam avatar Feb 24 '20 17:02 onqtam

Huh, well this says exactly the opposite from the comment on #229! So still only std::dec is being set, I think we should either reset all or none. Thoughts?

Saalvage avatar Jan 11 '22 01:01 Saalvage

Adapting my comment from #229

  • doctest should isolate its ios flags from those of the test code, i.e. if the code I'm testing sets std::hex, doctest should not produce hexadecimal numbers for its own output (test indicates, number of passing jobs etc)
  • doctest should allow setting some/all ios flags for its own output - using some separate, dedicated mechanism (either exposing a stream or via getters/setters which work with ios_base::fmtflags values).

eyalroz avatar Jan 11 '22 15:01 eyalroz