add GoogleTest gtest-1.7.0 and simple hello_gtest (preparation for unit tests)

This commit is contained in:
Erwin Coumans
2014-01-31 00:18:35 -08:00
parent 2901d4682e
commit d37a40caf1
38 changed files with 31272 additions and 0 deletions

38
Test/hello_gtest/main.cpp Normal file
View File

@@ -0,0 +1,38 @@
/////////////////////////////
// In the header file
#include <sstream>
using namespace std;
class Salutation
{
public:
static string greet(const string& name);
};
///////////////////////////////////////
// In the class implementation file
string Salutation::greet(const string& name) {
ostringstream s;
s << "Hello " << name << "!";
return s.str();
}
///////////////////////////////////////////
// In the test file
#include <gtest/gtest.h>
TEST(SalutationTest, Static) {
EXPECT_EQ(string("Hello World!"), Salutation::greet("World"));
}
int main(int argc, char **argv) {
#if _MSC_VER
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//void *testWhetherMemoryLeakDetectionWorks = malloc(1);
#endif
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}