Created
February 26, 2020 12:05
-
-
Save bradphelan/0bb9397ea7b49f45122908b1a9da061f to your computer and use it in GitHub Desktop.
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
TEST(RANGE, LVALUE){ | |
auto vector = IRange(3,5) | ToVector(); | |
auto mvector = vector | Map([](int i){return i+1;}) | ToVector(); | |
// Check the vector has not been moved | |
ASSERT_EQ(2,vector.size()); | |
ASSERT_EQ(3,vector[0]); | |
ASSERT_EQ(4,vector[1]); | |
// Check the result has what it needs | |
ASSERT_EQ(2,mvector.size()); | |
ASSERT_EQ(4,mvector[0]); | |
ASSERT_EQ(5,mvector[1]); | |
} |
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
TEST(RANGE, MOVED_LVALUE){ | |
auto vector = IRange(3,5) | ToVector(); | |
auto mvector = std::move(vector) | Map([](int i){return i+1;}) | ToVector(); | |
// Check the vector has not been copied but moved | |
ASSERT_EQ(0,vector.size()); | |
// Check the result has what it needs | |
ASSERT_EQ(2,mvector.size()); | |
ASSERT_EQ(4,mvector[0]); | |
ASSERT_EQ(5,mvector[1]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment