-
-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
g_oss
is causing incorrect stringification results
#567
Comments
So I fixed the MSVC 2015 builds and the obvious bugs in Basically, I changed it so that whenever However the second example still behaves weirdly, but if I change |
Making |
merged the PR #569 |
Edit: I have now published a possible fix at #569!
I'm currently working on a stringification utility for STL classes, and I've discovered an obscure bug that manifests in two slightly different ways:
1.
When an argument to a
MessageBuilder
is stringified via being written to anostream
(operator<<
) the result of that stringification is accidentally prepended to the result of theMessageBuilder
.Example:
Expected result:
AB
Actual result:
AAB
This can be avoided by first writing the
String
into an object like so:doctest::String s = doctest::toString(B()); FAIL(s);
2.
When an
operator<<
utilizestoString
which in turn executes its function via writing to a stream.Arguably this is a bit contrived, since you usually wouldn't use
toString
in anoperator<<
overload, but it still shows a weakness in design, which demonstrates that simply givingMessageBuilders
s their own thread local osstream won't solve this problem entirely.There might be a less contrived instance of this bug lurking somewhere!
Example:
Expected result:
CBA
Actual result:
ACA
The stream that is used to stringify
B
needs to be used again to stringifyA
, this messes things up.I'm honestly not entirely sure on how to solve this, I think the idea of having a single string buffer will need to be abandoned.
My first approach was simply moving the logic of resetting the buffer into the result function, this solves 1. but modifies 2.'s result to be
BCA
, which is still incorrect!My current progress can be found on https://github.com/Saalvage/doctest/tree/tlss
Some input would be appreciated!
Extra information
The text was updated successfully, but these errors were encountered: