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