Last active
January 31, 2018 17:24
-
-
Save lithiumhead/bb6d522ba13363b74ba4201d1d21a750 to your computer and use it in GitHub Desktop.
TEST_F() and code in same file - Test Pass
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 <iostream> | |
#include <gtest/gtest.h> | |
struct BankAccount { | |
int balance = 0; | |
BankAccount() { | |
} | |
explicit BankAccount(const int balance) | |
: balance{balance} { | |
} | |
}; | |
struct BankAccountTest : testing::Test { | |
BankAccount *account; | |
BankAccountTest() { | |
account = new BankAccount; | |
} | |
~BankAccountTest() { | |
delete account; | |
} | |
}; | |
TEST_F(BankAccountTest, BankAccountStartsEmpty) { | |
EXPECT_EQ(0, account->balance); | |
} | |
int main(int argc, char **argv) { | |
::testing::InitGoogleTest(&argc, argv); | |
return RUN_ALL_TESTS(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment