Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <math.h>
- #include "gtest/gtest.h"
- // Unit test
- // 1. The unit test must run extremely fast (within Milliseconds)
- // 2. Must be able to run independently
- // 3. Doesn't depend upon any external input
- using namespace std;
- class MyClass
- {
- public:
- int value;
- MyClass(int value)
- {
- this->value = value;
- }
- void Increment()
- {
- value += 5;
- }
- int getValue()
- {
- return value;
- }
- };
- struct MyClassTest : public testing::Test
- {
- MyClass* mc;
- void SetUp()
- {
- cout << " alive" << endl;
- mc = new MyClass(100);
- }
- void TearDown()
- {
- cout << "Tear down" << endl;
- delete mc;
- }
- };
- TEST_F(MyClassTest, TextFixture_test1)
- {
- mc->Increment();
- ASSERT_EQ(mc->getValue(), 105);
- }
- TEST(TestName, incremented_by_10)
- {
- int value = 100;
- int increment = 10;
- value = value + increment;
- ASSERT_EQ(value, 110);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement