changed macro names: EXPECT -> REQUIRE, *_NOT -> *_FALSE

This commit is contained in:
Phil Nash
2010-12-14 09:00:09 +00:00
parent de77ff3b29
commit a2d20951a2
7 changed files with 67 additions and 67 deletions
+46 -47
View File
@@ -29,23 +29,22 @@ struct TestData
double double_pi;
};
// These tests all use the CHECK macro, which continues if the specific test fails.
// This allows us to see all results, even if an earlier check fails - which is
// particularly important for the "should fail" checks
// The "failing" tests all use the CHECK macro, which continues if the specific test fails.
// This allows us to see all results, even if an earlier check fails
// Equality tests
TEST_CASE( "succeeding/conditions/equality", "Equality checks that should succeed" )
{
TestData data;
CHECK( data.int_seven == 7 );
CHECK( data.float_nine_point_one == Approx( 9.1f ) );
CHECK( data.double_pi == Approx( 3.1415926535 ) );
CHECK( data.str_hello == "hello" );
CHECK( data.str_hello.size() == 5 );
REQUIRE( data.int_seven == 7 );
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) );
REQUIRE( data.double_pi == Approx( 3.1415926535 ) );
REQUIRE( data.str_hello == "hello" );
REQUIRE( data.str_hello.size() == 5 );
double x = 1.1 + 0.1 + 0.1;
CHECK( x == Approx( 1.3 ) );
REQUIRE( x == Approx( 1.3 ) );
}
TEST_CASE( "failing/conditions/equality", "Equality checks that should fail" )
@@ -73,17 +72,17 @@ TEST_CASE( "succeeding/conditions/inequality", "Inequality checks that should su
{
TestData data;
CHECK( data.int_seven != 6 );
CHECK( data.int_seven != 8 );
CHECK( data.float_nine_point_one != Approx( 9.11f ) );
CHECK( data.float_nine_point_one != Approx( 9.0f ) );
CHECK( data.float_nine_point_one != 1 );
CHECK( data.float_nine_point_one != 0 );
CHECK( data.double_pi != Approx( 3.1415 ) );
CHECK( data.str_hello != "goodbye" );
CHECK( data.str_hello != "hell" );
CHECK( data.str_hello != "hello1" );
CHECK( data.str_hello.size() != 6 );
REQUIRE( data.int_seven != 6 );
REQUIRE( data.int_seven != 8 );
REQUIRE( data.float_nine_point_one != Approx( 9.11f ) );
REQUIRE( data.float_nine_point_one != Approx( 9.0f ) );
REQUIRE( data.float_nine_point_one != 1 );
REQUIRE( data.float_nine_point_one != 0 );
REQUIRE( data.double_pi != Approx( 3.1415 ) );
REQUIRE( data.str_hello != "goodbye" );
REQUIRE( data.str_hello != "hell" );
REQUIRE( data.str_hello != "hello1" );
REQUIRE( data.str_hello.size() != 6 );
}
TEST_CASE( "failing/conditions/inequality", "Inequality checks that should fails" )
@@ -102,27 +101,27 @@ TEST_CASE( "succeeding/conditions/ordered", "Ordering comparison checks that sho
{
TestData data;
CHECK( data.int_seven < 8 );
CHECK( data.int_seven > 6 );
CHECK( data.int_seven > 0 );
CHECK( data.int_seven > -1 );
REQUIRE( data.int_seven < 8 );
REQUIRE( data.int_seven > 6 );
REQUIRE( data.int_seven > 0 );
REQUIRE( data.int_seven > -1 );
CHECK( data.int_seven >= 7 );
CHECK( data.int_seven >= 6 );
CHECK( data.int_seven <= 7 );
CHECK( data.int_seven <= 8 );
REQUIRE( data.int_seven >= 7 );
REQUIRE( data.int_seven >= 6 );
REQUIRE( data.int_seven <= 7 );
REQUIRE( data.int_seven <= 8 );
CHECK( data.float_nine_point_one > 9 );
CHECK( data.float_nine_point_one < 10 );
CHECK( data.float_nine_point_one < 9.2 );
REQUIRE( data.float_nine_point_one > 9 );
REQUIRE( data.float_nine_point_one < 10 );
REQUIRE( data.float_nine_point_one < 9.2 );
CHECK( data.str_hello <= "hello" );
CHECK( data.str_hello >= "hello" );
REQUIRE( data.str_hello <= "hello" );
REQUIRE( data.str_hello >= "hello" );
CHECK( data.str_hello < "hellp" );
CHECK( data.str_hello < "zebra" );
CHECK( data.str_hello > "hellm" );
CHECK( data.str_hello > "a" );
REQUIRE( data.str_hello < "hellp" );
REQUIRE( data.str_hello < "zebra" );
REQUIRE( data.str_hello > "hellm" );
REQUIRE( data.str_hello > "a" );
}
TEST_CASE( "failing/conditions/ordered", "Ordering comparison checks that should fail" )
@@ -159,20 +158,20 @@ TEST_CASE( "failing/conditions/ordered", "Ordering comparison checks that should
// This means we can't isolate it when we decompose. The simple CHECK( !false ) form, therefore,
// cannot have the operand value extracted. The test will work correctly, and the situation
// is detected and a warning issued.
// An alternative form of the macros (CHECK_NOT and EXPECT_NOT) can be used instead to capture
// An alternative form of the macros (CHECK_FALSE and REQUIRE_FALSE) can be used instead to capture
// the operand value.
TEST_CASE( "succeeding/conditions/not", "'Not' checks that should succeed" )
{
bool falseValue = false;
CHECK( !false );
CHECK_NOT( false );
REQUIRE( !false );
REQUIRE_FALSE( false );
CHECK( !falseValue );
CHECK_NOT( falseValue );
REQUIRE( !falseValue );
REQUIRE_FALSE( falseValue );
CHECK( !(1 == 2) );
CHECK_NOT( 1 == 2 );
REQUIRE( !(1 == 2) );
REQUIRE_FALSE( 1 == 2 );
}
TEST_CASE( "failing/conditions/not", "'Not' checks that should fail" )
@@ -180,12 +179,12 @@ TEST_CASE( "failing/conditions/not", "'Not' checks that should fail" )
bool trueValue = true;
CHECK( !true );
CHECK_NOT( true );
CHECK_FALSE( true );
CHECK( !trueValue );
CHECK_NOT( trueValue );
CHECK_FALSE( trueValue );
CHECK( !(1 == 1) );
CHECK_NOT( 1 == 1 );
CHECK_FALSE( 1 == 1 );
}