googletest simple example
# Makefile for gtest examples | |
GOOGLE_TEST_LIB = gtest | |
GOOGLE_TEST_INCLUDE = /usr/local/include | |
G++ = g++ | |
G++_FLAGS = -c -Wall -I $(GOOGLE_TEST_INCLUDE) | |
LD_FLAGS = -L /usr/local/lib -l $(GOOGLE_TEST_LIB) -l pthread | |
OBJECTS = main.o string-compare.o | |
TARGET = string-compare | |
all: $(TARGET) | |
$(TARGET): $(OBJECTS) | |
g++ -o $(TARGET) $(OBJECTS) $(LD_FLAGS) | |
%.o : %.cpp | |
$(G++) $(G++_FLAGS) $< | |
clean: | |
rm -f $(TARGET) $(OBJECTS) | |
.PHONY: all clean |
#include <gtest/gtest.h> // googletest header file | |
#include <string> | |
using std::string; | |
const char *actualValTrue = "hello gtest"; | |
const char *actualValFalse = "hello world"; | |
const char *expectVal = "hello gtest"; | |
TEST(StrCompare, CStrEqual) { | |
EXPECT_STREQ(expectVal, actualValTrue); | |
} | |
TEST(StrCompare, CStrNotEqual) { | |
EXPECT_STREQ(expectVal, actualValFalse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment