Gtest ??????????
???????????? ???????[ 2014/3/18 15:31:14 ] ??????????????? ???? ????
???????????????????????demo???
????===========linux????gtest=================
----------------code.cpp-------------------
#include "code.h"
int f( int a ){ return a+1;}
int b( int b ){ return b+2;}
----------------code_test.cpp-------------------
#include "code.h"
#include <gtest/gtest.h>
TEST( TEST_A??NAME ){//TEST_A ??????????????? NAME ?????????
EXPECT_EQ( 2??f( 1 ) );//?????????к???f???????1??????????????2
EXPECT_EQ( 3??f( 2 ) );
}
TEST( TEST_B??NAME ){
EXPECT_EQ( 4??b( 2 ) );
}
----------------main_test.cpp-------------------
#include <gtest/gtest.h
#include <iostream>
int main(int argc?? char **argv) {
testing::InitGoogleTest(&argc?? argv);
return RUN_ALL_TESTS();
}
----------------????--------------------------
gcc $(gtest-config --ldflags --libs) -o main_test code.cpp code_test.cpp main_test.cpp -I /home/sosotest/include -lgtest -L /home/sosotest/lib
----------------????--------------------------
./main_test
[==========] Running 4 tests from 4 test cases.
[----------] Global test environment set-up.
[----------] 1 test from TEST_A
[ RUN ] TEST_A.NAME
[ OK ] TEST_A.NAME (0 ms)
[----------] 1 test from TEST_A (0 ms total)
[----------] 1 test from TEST_B
[ RUN ] TEST_B.NAME
[ OK ] TEST_B.NAME (0 ms)
[----------] 1 test from TEST_B (0 ms total)
[----------] Global test environment tear-down
[==========] 2 tests from 2 test cases ran. (0 ms total)
[ PASSED ] 2 tests.
??????
???·???
??????????????????
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