?????????gtest????д????????????test_main.cpp
#include <iostream>
#include <gtest/gtest.h>
using namespace std;
int Foo(int a??int b)
{
return a+b;
}
TEST(FooTest?? ZeroEqual)
{
ASSERT_EQ(0??0);
}
TEST(FooTest?? HandleNoneZeroInput)
{
EXPECT_EQ(12??Foo(4?? 10));
EXPECT_EQ(6?? Foo(30?? 18));
}
int main(int argc?? char* argv[])
{
testing::InitGoogleTest(&argc?? argv);
return RUN_ALL_TESTS();
}
????????gtest?????MakeFile????
TARGET=test_main
all:
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
g++  $(gtest-config --cppflags --cxxflags) -o $(TARGET).o -c test_main.cpp
g++  $(gtest-config --ldflags --libs) -o $(TARGET) $(TARGET).o
clean:
rm -rf *.o $(TARGET)
??????????????????????
cxy-/home/chenxueyou/gtest$ make
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
g++   -o test_main.o -c test_main.cpp
g++  -o test_main test_main.o
test_main.o: In function `FooTest_ZeroEqual_Test::TestBody()':
test_main.cpp:(.text+0x9e): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type?? char const*?? int?? char const*)'
...
??????????????????????????undefined reference??????????????????????????????????????????????????????????????????????
????g++  -o test_main.o -c test_main.cpp
????g++  -o test_main test_main.o
???????????????????gtest????????????????gtest??????