gtestд?????????????????????????
???????????? ???????[ 2015/8/24 11:29:45 ] ??????????????? ????????
?????????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??????
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11