Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gtest/gtest.h>
- #include <vector>
- void Function (std::vector <int>& v)
- {
- for (auto x = v.begin (); x != v.end (); ++x) {
- if ( (* x) == 42) {
- v.erase (x);
- }
- }
- }
- class FunctionTest : public ::testing::Test
- {
- protected:
- virtual void SetUp () {};
- virtual void TearDown () {};
- };
- TEST_F (FunctionTest, EmptyVectorProcessedSuccess)
- {
- // Arrange.
- std::vector <int> testVector {};
- // Act.
- Function (testVector);
- // Assert.
- EXPECT_EQ (testVector.size (), 0);
- }
- TEST_F (FunctionTest, NotEmptyVectorProcessedWithRemovingSuccess)
- {
- // Arrange.
- std::vector <int> etalonVector {1, 3};
- std::vector <int> testVector {1, 42, 3};
- // Act.
- Function (testVector);
- // Assert.
- ASSERT_EQ (etalonVector.size (), testVector.size () );
- for (int i = 0; i < etalonVector.size (); ++i) {
- EXPECT_EQ (etalonVector [i], testVector [i]);
- }
- }
- TEST_F (FunctionTest, NotEmptyVectorProcessedWithoutRemovingSuccess)
- {
- // Arrange.
- std::vector <int> etalonVector {1, 2, 3};
- std::vector <int> testVector {1, 2, 3};
- // Act.
- Function (testVector);
- // Assert.
- ASSERT_EQ (etalonVector.size (), testVector.size () );
- for (int i = 0; i < etalonVector.size (); ++i) {
- EXPECT_EQ (etalonVector [i], testVector [i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement