Live Hacking: Switch To googletest#
Git Submodule#
In the toplevel directory,
$ git submodule add https://github.com/google/googletest.git
Note
Cloners must then, at the toplevel,
$ git submodule init
$ git submodule update
Add googletest to toplevel CMakeLists.txt
Establish Tests: Demo#
Pull
cmake-testsintotests/CMakeLists.txt(and comment out most of what’s there)Add single
test-demo.cppTEST()pass
FAIL()ASSERT_EQ() << "..."
TEST_F()#include <gtest/gtest.h> class SimpleFixture : public ::testing::Test { ... }; TEST_F(SimpleFixture, MyFirstSuite) { ... }
Straightforward main() Conversion#
Add
test_find.cppto new runner executable, and build⟶ works (WTF?)
⟶ tallk a little about linking
main()
Morph
test-find.cppMorph
test-funny-overflow-file.cppNote: fixture!
Morph
test-csv.cppNote: two tests!
Fix Shortcomings#
Make two tests out of one in
test-csv.cpp⟶ trivialCreate a fixture class for this tempfile crap
Pull in
temp-file-fixtureinto new filetests/tempfile.h
tests/test-funny-overflow-file.cpp: add null suite class that void-derives from fixturetests/test-csv.cpp: same