出自flip the world

Googletest:修訂間差異

Tommy​(留言 | 貢獻)
已建立頁面,內容為 "* src ** git clone https://github.com/google/googletest"
 
Tommy​(留言 | 貢獻)
Add a lead sentence
 
(未顯示同一使用者於中間所作的 2次修訂)
第1行: 第1行:
* src
'''Googletest''' is Google's C++ unit-testing framework. These notes cover building it from source and linking it against your own code.
** git clone https://github.com/google/googletest
 
== Download SRC ==
* git clone https://github.com/google/googletest
 
== Build with samples ==
* cd googletest
* mkdir build & cd build
* cmake -Dgtest_build_samples=ON ..
 
== Compile with your functions ==
* g++ -o gtest_main.cc adc_unittest.c adc_test.c -I ../include/ -L ../../build/lib/ -lgtest -lgtest_main -lpthread
 
== Result ==
<pre>
./gtest_main.cc
Running main() from /home/tommy/Projects/google_test/googletest/googletest/src/gtest_main.cc
[==========] Running 3 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN      ] FactorialTest.Negative
[      OK ] FactorialTest.Negative (0 ms)
[ RUN      ] FactorialTest.Zero
[      OK ] FactorialTest.Zero (0 ms)
[ RUN      ] FactorialTest.Positive
adc_unittest.c:109: Failure
Expected equality of these values:
  40320
  adc_raw_to_voltage(8)
    Which is: 6
[  FAILED  ] FactorialTest.Positive (0 ms)
[----------] 3 tests from FactorialTest (0 ms total)
 
[----------] Global test environment tear-down
[==========] 3 tests from 1 test suite ran. (0 ms total)
[  PASSED  ] 2 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] FactorialTest.Positive
 
1 FAILED TEST
 
</pre>
 
[[Category:Software and Tools]]

2026年8月23日 (日) 17:57的最新修訂

Googletest is Google's C++ unit-testing framework. These notes cover building it from source and linking it against your own code.

Download SRC

Build with samples

  • cd googletest
  • mkdir build & cd build
  • cmake -Dgtest_build_samples=ON ..

Compile with your functions

  • g++ -o gtest_main.cc adc_unittest.c adc_test.c -I ../include/ -L ../../build/lib/ -lgtest -lgtest_main -lpthread

Result

./gtest_main.cc 
Running main() from /home/tommy/Projects/google_test/googletest/googletest/src/gtest_main.cc
[==========] Running 3 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN      ] FactorialTest.Negative
[       OK ] FactorialTest.Negative (0 ms)
[ RUN      ] FactorialTest.Zero
[       OK ] FactorialTest.Zero (0 ms)
[ RUN      ] FactorialTest.Positive
adc_unittest.c:109: Failure
Expected equality of these values:
  40320
  adc_raw_to_voltage(8)
    Which is: 6
[  FAILED  ] FactorialTest.Positive (0 ms)
[----------] 3 tests from FactorialTest (0 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test suite ran. (0 ms total)
[  PASSED  ] 2 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] FactorialTest.Positive

 1 FAILED TEST