test: Add unit tests for ExecutionResult constructors#435
Merged
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 |
Collaborator
|
Do you want to try to cover the constexpr constructor line? I think this might do it |
0ebcea2 to
6029a8c
Compare
gumb0
reviewed
Jul 22, 2020
|
|
||
| TEST(api, execution_result_bool_constructor) | ||
| { | ||
| bool success = false; |
Collaborator
There was a problem hiding this comment.
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.
gumb0
approved these changes
Jul 22, 2020
6029a8c to
4804de3
Compare
axic
commented
Jul 22, 2020
|
|
||
| TEST(api, execution_result_value) | ||
| { | ||
| const ExecutionResult result = 1234; |
Member
Author
There was a problem hiding this comment.
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
gumb0
approved these changes
Jul 22, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/Voiddon't get assigned via the explicit constructor, but by setting thetrappedvariable. We can figure out the case with coverage later (cc @chfast).