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.
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.
I am having some trouble finding the header that contains ElementsAre
There was a problem hiding this comment.
It should be in gmock/gmock.h
There was a problem hiding this comment.
There was a problem hiding this comment.
I have tried gmock/gmock.h and am getting "'ElementsAre' was not declared in this scope"
There was a problem hiding this comment.
Probably you're missing the namespace? testing::ElementsAre
There was a problem hiding this comment.
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.
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.
| 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.
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.
When I try, it spits out a number of errors, does that imply that the == operator is not implemented properly?
adityashirodkar
left a comment
There was a problem hiding this comment.
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
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.