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-tests
intotests/CMakeLists.txt
(and comment out most of what’s there)Add single
test-demo.cpp
TEST()
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.cpp
to new runner executable, and build⟶ works (WTF?)
⟶ tallk a little about linking
main()
Morph
test-find.cpp
Morph
test-funny-overflow-file.cpp
Note: fixture!
Morph
test-csv.cpp
Note: 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-fixture
into new filetests/tempfile.h
tests/test-funny-overflow-file.cpp
: add null suite class that void-derives from fixturetests/test-csv.cpp
: same