Comments (4)
This is planned to be fixed (the way Catch does it) in 1.1 - I will also limit the expression decomposition to only binary expressions the same way.
Unfortunately the release of 1.1 was delayed but it will come. Thanks for the report!
I think that in this particular case 9 || 1
gets evaluated first and the result is a bool, and then that bool is compared to 1 which results in a bool which is compared to 8 which gets converted to a bool true
and so the test "passes". Adding parenthesis should fix this - like this: (1==9) || (1==8)
from doctest.
That's great news!
This is happening because of the way ExpressionDecomposer() works, right?
I do not think that 9 || 1
gets evaluated first. It seems to me that doctest is expanding
CHECK(1==9 || 1==8);
as
ExpressionDecomposer() << 1==9 || 1==8;
Taking operator precedence, operator << it's the first to evaluate, producing an instance of Expression_lhs.
Then the first == is evaluated, and an instance of Result is generated. Call it "r".
So in the end, this is what the compiler sees:
r || 1==8;
As Result has a bool conversion operator that, in this case, gets evaluated to true, the whole expression is evaluated to true.
I see that this line
//template <typename R> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator||(const R&);
is commented out in the Result class. I imagine that in version 1.1 you are going to take out the comment and then the same result that in Catch will be obtained.
Ok, thank you for your great library.
from doctest.
actually you are right :D
from doctest.
I forgot this issue and I logged another one for the same thing. It should be done in the dev branch - only the reasonable expressions will be allowed and for anything else a static assert with a message will be used. Version 1.1 incoming in the next few days!
from doctest.
Related Issues (20)
- compiling with fastmath std::isnan(value)^flipped always evaluates to false
- Doctest segfault with CHECK in implement w/o main HOT 1
- Compilation error on minimal function taking and returning std::vector<std::pair<int, int>> HOT 3
- Abort execution of a subcase without halting the entire test case
- Request: Control via environment variables
- Suggestion: document a simpler CMake integration via FetchContent HOT 2
- Tests fail to compile: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage], etc HOT 2
- Warning from new CMake HOT 3
- Add DISCOVERY_MODE to doctest_discover_tests
- doctest outputs ANSI escapes to non-color TTYs, resulting in visible junk HOT 1
- Build error "error: zero as null pointer constant” (Xcode 15)
- doctest_discover_tests fails with ASAN on Windows HOT 1
- how to use with c++20 modules
- Add an "AND_GIVEN" macro for BDD-style test cases
- CodeQL warning in doctest header (use after free)
- Missing support for std::format HOT 1
- When one subcase fails, other independent sibling subcases are not executed anymore HOT 2
- Cannot include `doctest.h` in multiple translation units for Arduino (avr-gcc-7.3.0) HOT 1
- Feature request: predicate on CHECK_THROWS
- TYPE_TO_STRING does not work inside a TEST_SUITE / namespace HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doctest.