Skip to content

Instantly share code, notes, and snippets.

@lithiumhead
Last active January 31, 2018 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lithiumhead/bb6d522ba13363b74ba4201d1d21a750 to your computer and use it in GitHub Desktop.
Save lithiumhead/bb6d522ba13363b74ba4201d1d21a750 to your computer and use it in GitHub Desktop.
TEST_F() and code in same file - Test Pass
#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