From 39bfbe557df02a0b28c93b9b20032075434a9678 Mon Sep 17 00:00:00 2001 From: Gennadiy Rozental Date: Sun, 21 Oct 2007 20:59:15 +0000 Subject: [PATCH] correct run rules in examples make example 2 more pronounced removed unnecessary ; in example 4 and 5 new alias test in test directory msvc 6.5 should use static lib test case for new tools added [SVN r40271] --- example/.cvsignore | 1 - example/Jamfile.v2 | 20 ++++++++-------- example/test_case_template_example.cpp | 4 ++++ example/unit_test_example_02.cpp | 2 +- example/unit_test_example_04.cpp | 8 +++---- example/unit_test_example_05.cpp | 2 +- test/Jamfile.v2 | 10 +++++++- test/test_files/test_tools_test.pattern | 32 +++++++++++++++---------- test/test_tools_test.cpp | 27 +++++++++++++++++++++ 9 files changed, 75 insertions(+), 31 deletions(-) delete mode 100644 example/.cvsignore diff --git a/example/.cvsignore b/example/.cvsignore deleted file mode 100644 index ba077a40..00000000 --- a/example/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 75cb3608..0dbc6436 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -31,13 +31,13 @@ explicit prg_exec_monitor ; test-suite boost_test_examples : [ run exec_mon_example.cpp prg_exec_monitor ] - [ run prg_exec_example.cpp prg_exec_monitor ] + [ run-fail prg_exec_example.cpp prg_exec_monitor ] - [ run test_case_template_example.cpp unit_test_framework ] + [ run-fail test_case_template_example.cpp unit_test_framework/static ] - [ run-fail unit_test_example_01.cpp ] - [ run unit_test_example_02.cpp unit_test_framework ] - [ run unit_test_example_03.cpp unit_test_framework ] + [ run-fail unit_test_example_01.cpp unit_test_framework ] + [ run-fail unit_test_example_02.cpp unit_test_framework/static ] + [ run-fail unit_test_example_03.cpp unit_test_framework/static ] [ run-fail unit_test_example_04.cpp unit_test_framework ] [ run-fail unit_test_example_05.cpp unit_test_framework ] [ run-fail unit_test_example_06.cpp unit_test_framework ] @@ -45,14 +45,14 @@ test-suite boost_test_examples [ run unit_test_example_08.cpp unit_test_framework ] [ run unit_test_example_09_1.cpp unit_test_example_09_2.cpp unit_test_framework ] - [ run-fail unit_test_example_10.cpp unit_test_framework ] - [ run-fail unit_test_example_11.cpp unit_test_framework ] - [ link unit_test_example_12.cpp unit_test_framework ] + [ run-fail unit_test_example_10.cpp unit_test_framework/static ] + [ run-fail unit_test_example_11.cpp unit_test_framework/static ] + [ link unit_test_example_12.cpp unit_test_framework/static ] [ run est_example1.cpp unit_test_framework ] - [ run est_example2.cpp unit_test_framework ] + [ run-fail est_example2.cpp unit_test_framework ] - [ run logged_exp_example.cpp unit_test_framework ] + [ run-fail logged_exp_example.cpp unit_test_framework ] [ run named_param_example.cpp ] ; diff --git a/example/test_case_template_example.cpp b/example/test_case_template_example.cpp index 14933e00..51351351 100644 --- a/example/test_case_template_example.cpp +++ b/example/test_case_template_example.cpp @@ -6,6 +6,10 @@ // See http://www.boost.org/libs/test for the library home page. // Boost.Test +#ifdef BOOST_MSVC +# pragma warning(disable: C4345) +#endif + #include #include using boost::unit_test::test_suite; diff --git a/example/unit_test_example_02.cpp b/example/unit_test_example_02.cpp index e49ad55e..e196639f 100644 --- a/example/unit_test_example_02.cpp +++ b/example/unit_test_example_02.cpp @@ -21,7 +21,7 @@ void free_test_function() // reports 'unknown location(0): fatal error in "free_test_function": memory access violation // d:\source code\boost\libs\test\example\unit_test_example_02.cpp(25): last checkpoint' - int* p = (int*)0; + int* p = (int*)0x01; BOOST_CHECK( *p == 0 ); } diff --git a/example/unit_test_example_04.cpp b/example/unit_test_example_04.cpp index 8719d64f..9e0e586a 100644 --- a/example/unit_test_example_04.cpp +++ b/example/unit_test_example_04.cpp @@ -12,7 +12,7 @@ //____________________________________________________________________________// // automatically registerred test cases could be organized in test suites -BOOST_AUTO_TEST_SUITE( my_suite1 ); +BOOST_AUTO_TEST_SUITE( my_suite1 ) BOOST_AUTO_TEST_CASE( my_test1 ) { @@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE( my_test2 ) BOOST_CHECK_EQUAL( i, 0 ); } -BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_SUITE_END() //____________________________________________________________________________// @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE( my_test3 ) //____________________________________________________________________________// -BOOST_AUTO_TEST_SUITE( my_suite2 ); +BOOST_AUTO_TEST_SUITE( my_suite2 ) // this test case belongs to suite2 test suite BOOST_AUTO_TEST_CASE( my_test4 ) @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE( my_test4 ) BOOST_CHECK_EQUAL( i, 1 ); } -BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_SUITE_END() //____________________________________________________________________________// diff --git a/example/unit_test_example_05.cpp b/example/unit_test_example_05.cpp index c31b741d..9e4fb912 100644 --- a/example/unit_test_example_05.cpp +++ b/example/unit_test_example_05.cpp @@ -11,7 +11,7 @@ //____________________________________________________________________________// -BOOST_AUTO_TEST_SUITE( my_suite ); +BOOST_AUTO_TEST_SUITE( my_suite ) struct F { F() : i( 0 ) { BOOST_TEST_MESSAGE( "setup fixture" ); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 75fa6430..cad9415c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,7 +14,8 @@ rule test-btl-lib ( test-rule : test-name : lib-name ? : pattern_file * : source : #args : $(pattern_file) : #on - borland:-w-8080 + borland:-w-8080 + msvc-6.5:static BOOST_TEST_NO_AUTO_LINK=1 # requirements : $(test-name) ] ; @@ -55,3 +56,10 @@ test-suite "unit_test_framework_test" [ test-btl-lib run : token_iterator_test : boost_unit_test_framework ] [ test-btl-lib run : boost_check_equal_str : boost_unit_test_framework ] ; + + +# A target that runs all the tests +alias test : basics_test prg_exec_monitor_test unit_test_framework_test ; + +# Only run tests when explicitly requested +explicit test basics_test prg_exec_monitor_test unit_test_framework_test ; diff --git a/test/test_files/test_tools_test.pattern b/test/test_files/test_tools_test.pattern index 10f1282f..3036faed 100644 --- a/test/test_files/test_tools_test.pattern +++ b/test/test_files/test_tools_test.pattern @@ -33,23 +33,29 @@ 355: warning in "test_BOOST_CHECK_EQUAL": condition b1 == b2 is not satisfied [B(1) != B(2)] 361: error in "test_BOOST_CHECK_EQUAL": check c1 == c3 failed [C(0,100) != C(1,102)]. Index mismatch 362: error in "test_BOOST_CHECK_EQUAL": check c1 == c2 failed [C(0,100) != C(0,101)]. Id mismatch -392: error in "test_BOOST_CHECK_PREDICATE": check is_even( i ) failed for ( 17 ) -395: error in "test_BOOST_CHECK_PREDICATE": check not_equal_to()( i, 17 ) failed for ( 17, 17 ) -401: warning in "test_BOOST_CHECK_PREDICATE": condition moo( 12, i, j ) is not satisfied for ( 12, 17, 15 ) -409: error in "test_BOOST_CHECK_PREDICATE": check compare_lists( l1, l2 ) failed for ( , ). Different sizes [2!=0] -420: error in "test_BOOST_REQUIRE_PREDICATE": not aborted -422: fatal error in "test_BOOST_REQUIRE_PREDICATE": critical check less_equal()( arg2, arg1 ) failed for ( 2, 1 ) -443: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+7 } failed. +373: error in "test_BOOST_CHECK_LOGICAL_EXPR": check ++i != j failed [2 == 2] +375: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i < j failed [2 >= 2] +376: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i > j failed [2 <= 2] +383: error in "test_BOOST_CHECK_LOGICAL_EXPR": check i <= j failed [3 > 2] +384: error in "test_BOOST_CHECK_LOGICAL_EXPR": check j >= i failed [2 < 3] +389: error in "test_BOOST_CHECK_LOGICAL_EXPR": check str1 != str2 failed [test1 == test1] +419: error in "test_BOOST_CHECK_PREDICATE": check is_even( i ) failed for ( 17 ) +422: error in "test_BOOST_CHECK_PREDICATE": check not_equal_to()( i, 17 ) failed for ( 17, 17 ) +428: warning in "test_BOOST_CHECK_PREDICATE": condition moo( 12, i, j ) is not satisfied for ( 12, 17, 15 ) +436: error in "test_BOOST_CHECK_PREDICATE": check compare_lists( l1, l2 ) failed for ( , ). Different sizes [2!=0] +447: error in "test_BOOST_REQUIRE_PREDICATE": not aborted +449: fatal error in "test_BOOST_REQUIRE_PREDICATE": critical check less_equal()( arg2, arg1 ) failed for ( 2, 1 ) +470: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+7 } failed. Mismatch in a position 2: 4 != 3 Mismatch in a position 5: 7 != 6 -444: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+2 } failed. +471: error in "test_BOOST_CHECK_EQUAL_COLLECTIONS": check { testlist.begin(), testlist.end() } == { pattern, pattern+2 } failed. Collections size mismatch: 7 != 2 -453: error in "test_BOOST_CHECK_BITWISE_EQUAL": check (char)0x06 =.= (char)0x16 failed. +480: error in "test_BOOST_CHECK_BITWISE_EQUAL": check (char)0x06 =.= (char)0x16 failed. Mismatch in a position 4 -456: warning in "test_BOOST_CHECK_BITWISE_EQUAL": condition (char)0x26 =.= (char)0x04 is not satisfied. +483: warning in "test_BOOST_CHECK_BITWISE_EQUAL": condition (char)0x26 =.= (char)0x04 is not satisfied. Mismatch in a position 1 Mismatch in a position 5 -459: fatal error in "test_BOOST_CHECK_BITWISE_EQUAL": critical check (char)0x26 =.= (int)0x26 failed. +486: fatal error in "test_BOOST_CHECK_BITWISE_EQUAL": critical check (char)0x26 =.= (int)0x26 failed. Operands bit sizes mismatch: 8 != 32 still testing 1+1=2 @@ -58,6 +64,6 @@ struct A 0x14 20 0: fatal error in "test_BOOST_TEST_CHECKPOINT": C string: some error -494: last checkpoint: Going to do a silly things +521: last checkpoint: Going to do a silly things 0: fatal error in "test_BOOST_TEST_PASSPOINT": unknown type -505: last checkpoint +532: last checkpoint diff --git a/test/test_tools_test.cpp b/test/test_tools_test.cpp index 56c9c0c1..a6e30407 100644 --- a/test/test_tools_test.cpp +++ b/test/test_tools_test.cpp @@ -364,6 +364,33 @@ TEST_CASE( test_BOOST_CHECK_EQUAL ) //____________________________________________________________________________// +TEST_CASE( test_BOOST_CHECK_LOGICAL_EXPR ) +{ + int i=1; + int j=2; + BOOST_CHECK_NE( i, j ); + + BOOST_CHECK_NE( ++i, j ); + + BOOST_CHECK_LT( i, j ); + BOOST_CHECK_GT( i, j ); + + BOOST_CHECK_LE( i, j ); + BOOST_CHECK_GE( i, j ); + + ++i; + + BOOST_CHECK_LE( i, j ); + BOOST_CHECK_GE( j, i ); + + char const* str1 = "test1"; + char const* str2 = "test1"; + + BOOST_CHECK_NE( str1, str2 ); +} + +//____________________________________________________________________________// + bool is_even( int i ) { return i%2 == 0; } int foo( int arg, int mod ) { return arg % mod; } bool moo( int arg1, int arg2, int mod ) { return ((arg1+arg2) % mod) == 0; }