-
Notifications
You must be signed in to change notification settings - Fork 11
Improved constructor tests #60
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
Conversation
| if (std::is_same_v<T, NonTriviallyDefaultConstructible> || | ||
| std::is_same_v<T, NonTrivial>) { | ||
| if constexpr (std::is_scalar_v<T> || std::is_aggregate_v<T> || | ||
| !std::is_trivially_default_constructible_v<T>) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
ops, didnt see the negation.
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.
I am not sure if this is actually better than std::is_same_v<T, NonTriviallyDefaultConstructible> || std::is_same_v<T, NonTrivial>, we can do the comparison here not because the underlying is a scalar or an aggregate, it is because we know it has a well defined value-initialization.
| using T = TestFixture::T; | ||
| using InputIterator = TestFixture::InputIterator; | ||
|
|
||
| IV a(InputIterator{0}, InputIterator{IV::max_size() / 2}); | ||
| EXPECT_EQ(a.size(), IV::max_size() / 2); | ||
| if (!a.empty()) { | ||
| EXPECT_EQ(a.back().value, IV::max_size() / 2 - 1); | ||
| for (std::size_t n : {std::size_t(0), IV::max_size() / 2u, IV::max_size()}) { | ||
| // InputIterator | ||
| InputIterator::num_deref = 0u; | ||
| IV a(InputIterator{}, InputIterator{static_cast<int>(n)}); | ||
| EXPECT_EQ(a.size(), n); | ||
| for (int i = 0; i < static_cast<int>(n); ++i) { | ||
| EXPECT_EQ(a[i], T{i}); | ||
| } | ||
| // Only single-pass through input range | ||
| EXPECT_EQ(InputIterator::num_deref, n); | ||
|
|
||
| // RandomAccessIterator | ||
| IV b(a.begin(), a.end()); | ||
| EXPECT_EQ(b, a); |
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.
This is really helpful, thanks!
DeveloperPaul123
left a comment
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.
Looks good to me! Nice work 👍
|
@jbab this looks like it's been complete for awhile. I'm going to merge it in the next 24 hours unless there's still something to do here. |
No description provided.