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 into tests/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 ⟶ trivial

  • Create a fixture class for this tempfile crap

    • Pull in temp-file-fixture into new file tests/tempfile.h

  • tests/test-funny-overflow-file.cpp: add null suite class that void-derives from fixture

  • tests/test-csv.cpp: same