-
Notifications
You must be signed in to change notification settings - Fork 0
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
List and pair #8
Conversation
int counter = 1; | ||
for (auto iter = std::begin(int_list); iter != std::end(int_list); ++iter) | ||
{ | ||
EXPECT_EQ(*iter, counter); |
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.
There might be a reason it won't work for nostd::list, but there's a ElementsAre gtest matcher that you could try using like
EXPECT_THAT(int_list, ElementsAre(1,2,3,4,5,6,7,8));
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 having some trouble finding the header that contains ElementsAre
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.
It should be in gmock/gmock.h
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.
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 have tried gmock/gmock.h and am getting "'ElementsAre' was not declared in this scope"
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.
Probably you're missing the namespace? testing::ElementsAre
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.
It looks like in order to use ElementsAre, I would also need to implement a const iterator for nostd::list. Do you think that would be valuable?
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 wouldn't really recommend extending the nostd::list interface specifically for testing, but a const iterator seems like it would be useful generally. Do it if you think it will be quick and you have some spare time.
int counter = 1; | ||
for (auto iter = std::begin(int_list); iter != std::end(int_list); ++iter) | ||
{ | ||
EXPECT_EQ(*iter, counter); |
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.
pair<int, int> pair_1 = pair<int, int>(val_1, val_2); | ||
pair<int, int> pair_2 = pair<int, int>(val_1, val_2); | ||
|
||
EXPECT_EQ(pair_1 == pair_2, true); |
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.
Just FYI: Since pair::operator== is defined I think you can do
EXPECT_EQ(pair_1, pair_2)
and
EXPECT_NE(pair_1, pair_2)
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.
When I try, it spits out a number of errors, does that imply that the == operator is not implemented properly?
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.
Overall PR looks great. I think the biggest suggestion I would have is being consistent with formatting your code.
For example various ways functions are formatted in your files.
void fun()
{
// do something
}
vs
void fun()
{
// do something
}
vs
void fun() {
// do something
}
I recommend taking a look at https://google.github.io/styleguide/cppguide.html#Formatting
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.
LGTM
nostd implementations of list and pair, they are by no means a perfect copy of the std implementation. However, I feel like I don't want to put too much more time into it, until we know if we are going to move forward with this approach.