-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add unit tests for ExecutionResult constructors #435
Conversation
Codecov Report
@@ Coverage Diff @@
## master #435 +/- ##
=======================================
Coverage 99.32% 99.33%
=======================================
Files 50 50
Lines 14075 14107 +32
=======================================
+ Hits 13980 14013 +33
+ Misses 95 94 -1 |
Do you want to try to cover the constexpr constructor line? I think this might do it
|
0ebcea2
to
6029a8c
Compare
|
||
TEST(api, execution_result_bool_constructor) | ||
{ | ||
bool success = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would execute the constructor with this being const
, too, I'm not sure, just thought with non-const it's less probable to be optimized away.
Can be merged like this, anyway.
6029a8c
to
4804de3
Compare
|
||
TEST(api, execution_result_value) | ||
{ | ||
const ExecutionResult result = 1234; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const ExecutionResult result{1234};
results in
/Users/alex/Projects/fizzy/test/unittests/api_test.cpp:46:27: error: call to constructor of 'const fizzy::ExecutionResult' is ambiguous
const ExecutionResult result{1234};
^ ~~~~~~
/Users/alex/Projects/fizzy/lib/fizzy/execute.hpp:25:15: note: candidate constructor
constexpr ExecutionResult(uint64_t _value) noexcept : has_value{true}, value{_value} {}
^
/Users/alex/Projects/fizzy/lib/fizzy/execute.hpp:29:24: note: candidate constructor
constexpr explicit ExecutionResult(bool success) noexcept : trapped{!success} {}
^
/Users/alex/Projects/fizzy/lib/fizzy/execute.hpp:18:8: note: candidate constructor (the implicit move constructor)
struct ExecutionResult
^
/Users/alex/Projects/fizzy/lib/fizzy/execute.hpp:18:8: note: candidate constructor (the implicit copy constructor)
4804de3
to
37a1b40
Compare
37a1b40
to
879005f
Compare
Either coverage is wrong, or the explicit constructor is not called. With these tests we make sure that values are always correct even if in the case
Trap
/Void
don't get assigned via the explicit constructor, but by setting thetrapped
variable. We can figure out the case with coverage later (cc @chfast).