Created
May 6, 2017 19:40
-
-
Save kantoniak/23842ddef0a06fb0991f751ac7a4890b to your computer and use it in GitHub Desktop.
This file contains 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
#include <algorithm> | |
#include <vector> | |
#include <gtest/gtest.h> | |
class ExampleClass : public testing::Test { | |
protected: | |
virtual void SetUp() { | |
numbers.push_back(1); | |
numbers.push_back(2); | |
numbers.push_back(3); | |
} | |
virtual void TearDown() { | |
// Just for for fun | |
numbers.clear(); | |
} | |
std::vector<int> numbers; | |
}; | |
TEST_F(ExampleClass, Size) { | |
EXPECT_EQ(3, numbers.size()); | |
numbers.push_back(4); | |
EXPECT_EQ(4, numbers.size()); | |
numbers.clear(); | |
EXPECT_EQ(0, numbers.size()); | |
} | |
TEST_F(ExampleClass, Swap) { | |
EXPECT_EQ(2, numbers[1]); | |
EXPECT_EQ(3, numbers[2]); | |
std::swap(numbers[1], numbers[2]); | |
EXPECT_EQ(3, numbers[1]); | |
EXPECT_EQ(2, numbers[2]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment