Boost Test Library: examples and tests
Examples
1. The Program Execution Monitor example
2. The Test Execution Monitor example
3. The Unit Test Framework example 1
4. The Unit Test Framework example 2
5. The Unit Test Framework example 3
6. The Unit Test Framework example 4
7. The Unit Test Framework example 5
Tests
1. The Program Execution Monitor test 1
Rationale: intended to check an ability of the Program Execution
Monitor to catch a user exception.
Type: run-time-failure
Component needed: the Program Execution Monitor
Need test pattern: no
Expected output:
*** Error: C string:Test error by throwing C-style string exception
**** error return code 205
******* errors detected; see standard output for details ****
Result code: 205
2. The Program Execution Monitor test 2
Monitor to catch a system exeption.
Type: run-time-failure
Component needed: the Program Execution Monitor
Need test pattern: no
Expected output:
*** Error: integer divide by zero
**** error return code 210
******* errors detected; see standard output for details ****
Result code: 210
3. The Test Execution Monitor test 1
Rationale: intended to check an ability of the Test Execution Monitor
to catch non-zero return code from test_main
Type: run-time-failure
Component needed: the Test Execution Monitor
Need test pattern: no
Expected output:
<your_boost_home>\libs\test\src\test_main.cpp(49) : error in "call_tes
t_main": test test_main_result == 0 || test_main_result ==
boost::exit_success failed
*** Failures in "call_test_main"
Result code: 1
4. The Test Execution Monitor test 2
Rationale: intended to check an ability of the Test Execution Monitor
to catch and report test errors using the Test Tools.
Type: run-time-failure
Component needed: the Test Execution Monitor
Need test pattern: no
Expected output:
<your_boost_home>\libs\test\test\test_exec_fail2.cpp(14) : error in "c
all_test_main": test v == 2 failed
<your_boost_home>\libs\test\test\test_exec_fail2.cpp(15) : error in "c
all_test_main": sample BOOST_ERROR call
<your_boost_home>\libs\test\test\test_exec_fail2.cpp(16) : fatal error
in "call_test_main": test 2 == v failed
*** Failures in "call_test_main"
Result code: 3
5. The Test Execution Monitor test 3
Rationale: intended to check an ability of the Test Execution Monitor
to catch and report test errors using the Test Tools.
Type: run-time-failure
Component needed: the Test Execution Monitor
Need test pattern: no
Expected output:
<your_boost_home>\libs\test\test\test_exec_fail3.cpp(14) : error
in "call_test_main": test v == 2 failed
<your_boost_home>\libs\test\test\test_exec_fail3.cpp(15) : error in "c
all_test_main": test 2 == v failed
*** Failures in "call_test_main"
Result code: 2
6. The Test Execution Monitor test 4
Rationale: intended to check an ability of the Test Execution Monitor
to catch and report exceptions in tests.
Type: run-time-failure
Component needed: the Test Execution Monitor
Need test pattern: no
Expected output:
Exception in "call_test_main": C string:Test error by throwing C-
style string exception
*** Failures in "call_test_main"
Result code: -1
7. The Test Tools test
Rationale: detailed self test for the Test Tools. Intended to check
that every test tool is working properly, i.e. catch what is supposed
to catch and report the way it is supposed to report. Due to self
test nature the result code will always be non zero. The presence of
errors is detected by presence of lines with errors.
Type: run-time
Component needed: the Unit Test Framework
Need test pattern: no
Expected output: may vary from one compiler to another, example:
<your_boost_home>\libs\test\test\test_tools_test.cpp(91) : info: test
output.is_equal( (boost::test_toolbox::detail::wrapstrstream()
<< "<your_boost_home>\\libs\\test\\test\\test_tools_test.cpp" << "("
<< (__LINE__Var+31) << ") : " << "info: test i==2 passed\n").str() )
passed
<your_boost_home>\libs\test\test\test_tools_test.cpp(125) : info: test
output.is_equal( (boost::test_toolbox::detail::wrapstrstream()
<< "<your_boost_home>\\libs\\test\\test\\test_tools_test.cpp" << "("
<< (__LINE__Var+27) << ") : " << "info: test j < 5 passed\n").str() )
passed
testing BOOST_CHECK_CLOSE for float
testing BOOST_CHECK_CLOSE for double
testing BOOST_CHECK_CLOSE for long double
<your_boost_home>\libs\test\test\test_tools_test.cpp(549) : info: test
output.is_equal( (boost::test_toolbox::detail::wrapstrstream()
<< "<your_boost_home>\\libs\\test\\test\\test_tools_test.cpp" << "("
<< (__LINE__Var+17) << ") : " << "info: exception my_exception is
caught\n").str() ) passed
*** Failures in "Test Tools test"
Result code: 4
8. The Unit Test Framework online test
Rationale: intended to demonstrate how to use the program Execution
Monitor online (i.e. included into test program vs linked as a
separate library). It's compile-time check. Once compiled it means
that passed.
Type: compile-time
Component needed: none
Need test pattern (see below): no
Expected output:
*** No errors detected
Result code: 0
9. The Unit Test Framework output test stream test
Rationale: self test for output_test_stream Test Tool. validate that
all test mechanisms working properly. Include 5 test cases:
test_constructor, test_is_empty, test_check_length, test_is_equal,
test_match_pattern.
Type: run-time
Component needed: the Unit Test Framework
Need test pattern: no, but will generate 2 files automatically.
Expected output:
Running 5 test cases...
*** No errors detected
Result code: 0
10. The Unit Test Framework result report test
Rationale: the Unit Test Framework reporting facilities testing.
Check that all reports (short, conformation, detailed) are
constructed as expected. To do this output is matched vs. pattern
file. The pattern file result_report_test.pattern is located in test
directory. To run test match mode (default) does not provide any
arguments. To run test in save mode (this way you cne generate
pattern file) run test with the argument --save_pattern=yes.
Type: run-time
Component needed: the Test Execution Monitor
Need test pattern: yes
Expected output:
*** No errors detected
Result code: 0
11. The Unit Test Framework extension test
Rationale: the Unit Test Extention test.
Type: run-time
Component needed: the Unit Test Framework
Need test pattern: no
Expected output:
Running 6 test cases...
*** No errors detected
Result code: 0
12. The Unit Test Framework errors handling test
Rationale: intended to test that the Unit Test Framework properly
handle different errors during different stages of testing. Tesing
output is matchind the pattern file. The pattern file example is
located in test directory (Cause output includes your local path I
could not provide pattern file to everybody). To run test match mode
(default) does not provide any arguments. To run test in save mode
(this way you cne generate pattern file) run test with the argument --
save_pattern=yes.
Type: run-time
Component needed: the Test Execuiton Monitor
Need test pattern: yes
Expected output:
*** Failures in "call_test_main"
Result code: 120
|