From bf581e93662daf54e82836ad02860d08d09bb6ad Mon Sep 17 00:00:00 2001 From: Eric Paniagua Date: Sat, 29 Aug 2020 20:40:37 -0700 Subject: [PATCH] Hello, googletest! Signed-off-by: Eric Paniagua --- testing/.gitignore | 3 +++ testing/Makefile | 24 ++++++++++++++++++++++++ testing/hello-test.cpp | 13 +++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 testing/.gitignore create mode 100644 testing/Makefile create mode 100644 testing/hello-test.cpp diff --git a/testing/.gitignore b/testing/.gitignore new file mode 100644 index 00000000..ddf7a912 --- /dev/null +++ b/testing/.gitignore @@ -0,0 +1,3 @@ +bin/ +lib/ +obj/ diff --git a/testing/Makefile b/testing/Makefile new file mode 100644 index 00000000..19086700 --- /dev/null +++ b/testing/Makefile @@ -0,0 +1,24 @@ +GTEST_DIR=googletest/googletest +BIN_DIR=bin +LIB_DIR=lib +OBJ_DIR=obj + +all: run-hello-test + +run-hello-test: $(BIN_DIR)/hello-test + $(BIN_DIR)/hello-test + +$(BIN_DIR)/hello-test: hello-test.cpp $(LIB_DIR)/libgtest.so $(OBJ_DIR)/gtest_main.o + mkdir -p $(BIN_DIR) + g++ -o $(BIN_DIR)/hello-test -I$(GTEST_DIR)/include hello-test.cpp $(OBJ_DIR)/gtest_main.o $(LIB_DIR)/libgtest.so + +$(OBJ_DIR)/gtest_main.o: $(GTEST_DIR)/src/gtest_main.cc $(wildcard $(GTEST_DIR)/include/gtest/*.h) + mkdir -p $(OBJ_DIR) + g++ -o $(OBJ_DIR)/gtest_main.o -c -pthread -I$(GTEST_DIR)/include $(GTEST_DIR)/src/gtest_main.cc + +$(LIB_DIR)/libgtest.so: $(wildcard $(GTEST_DIR)/src/*.cc) $(wildcard $(GTEST_DIR)/include/gtest/*.h) + mkdir -p $(LIB_DIR) + g++ -o $(LIB_DIR)/libgtest.so -shared -fPIC -pthread -I$(GTEST_DIR) -I$(GTEST_DIR)/include $(GTEST_DIR)/src/gtest-all.cc + +clean: + rm $(BIN_DIR)/* $(LIB_DIR)/* $(OBJ_DIR)/* diff --git a/testing/hello-test.cpp b/testing/hello-test.cpp new file mode 100644 index 00000000..cf55d522 --- /dev/null +++ b/testing/hello-test.cpp @@ -0,0 +1,13 @@ +#include "gtest/gtest.h" + +namespace { + +TEST(Test, ThatPasses) { + EXPECT_TRUE(true); +} + +TEST(Test, ThatFails) { + EXPECT_TRUE(false); +} + +} // namespace