mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 05:59:32 +01:00 
			
		
		
		
	Some clean-ups
This commit is contained in:
		@@ -15,17 +15,10 @@
 | 
			
		||||
#include <limits>
 | 
			
		||||
 | 
			
		||||
struct TestData {
 | 
			
		||||
    TestData()
 | 
			
		||||
    :   int_seven( 7 ),
 | 
			
		||||
        str_hello( "hello" ),
 | 
			
		||||
        float_nine_point_one( 9.1f ),
 | 
			
		||||
        double_pi( 3.1415926535 )
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    int int_seven;
 | 
			
		||||
    std::string str_hello;
 | 
			
		||||
    float float_nine_point_one;
 | 
			
		||||
    double double_pi;
 | 
			
		||||
    int int_seven = 7;
 | 
			
		||||
    std::string str_hello = "hello";
 | 
			
		||||
    float float_nine_point_one = 9.1f;
 | 
			
		||||
    double double_pi = 3.1415926535;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -36,14 +29,13 @@ struct TestDef {
 | 
			
		||||
    TestDef& operator[]( const std::string& ) {
 | 
			
		||||
        return *this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 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( "Equality checks that should succeed", "" )
 | 
			
		||||
TEST_CASE( "Equality checks that should succeed" )
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    TestDef td;
 | 
			
		||||
@@ -83,7 +75,7 @@ TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" )
 | 
			
		||||
    CHECK( x == Approx( 1.301 ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "Inequality checks that should succeed", "" )
 | 
			
		||||
TEST_CASE( "Inequality checks that should succeed" )
 | 
			
		||||
{
 | 
			
		||||
    TestData data;
 | 
			
		||||
 | 
			
		||||
@@ -112,7 +104,7 @@ TEST_CASE( "Inequality checks that should fail", "[.][failing][!shouldfail]" )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Ordering comparison tests
 | 
			
		||||
TEST_CASE( "Ordering comparison checks that should succeed", "" )
 | 
			
		||||
TEST_CASE( "Ordering comparison checks that should succeed" )
 | 
			
		||||
{
 | 
			
		||||
    TestData data;
 | 
			
		||||
 | 
			
		||||
@@ -169,7 +161,7 @@ TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Comparisons with int literals
 | 
			
		||||
TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned", "" )
 | 
			
		||||
TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned" )
 | 
			
		||||
{
 | 
			
		||||
    int i = 1;
 | 
			
		||||
    unsigned int ui = 2;
 | 
			
		||||
@@ -207,7 +199,7 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne
 | 
			
		||||
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "comparisons between int variables", "" )
 | 
			
		||||
TEST_CASE( "comparisons between int variables" )
 | 
			
		||||
{
 | 
			
		||||
    long            long_var = 1L;
 | 
			
		||||
    unsigned char    unsigned_char_var = 1;
 | 
			
		||||
@@ -221,7 +213,7 @@ TEST_CASE( "comparisons between int variables", "" )
 | 
			
		||||
    REQUIRE( long_var == unsigned_long_var );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "comparisons between const int variables", "" )
 | 
			
		||||
TEST_CASE( "comparisons between const int variables" )
 | 
			
		||||
{
 | 
			
		||||
    const unsigned char     unsigned_char_var = 1;
 | 
			
		||||
    const unsigned short    unsigned_short_var = 1;
 | 
			
		||||
@@ -234,7 +226,7 @@ TEST_CASE( "comparisons between const int variables", "" )
 | 
			
		||||
    REQUIRE( unsigned_long_var == 1 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour", "" )
 | 
			
		||||
TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" )
 | 
			
		||||
{
 | 
			
		||||
    CHECK( ( -1 > 2u ) );
 | 
			
		||||
    CHECK( -1 > 2u );
 | 
			
		||||
@@ -247,7 +239,7 @@ TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++
 | 
			
		||||
    CHECK( minInt > 2u );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "Comparisons between ints where one side is computed", "" )
 | 
			
		||||
TEST_CASE( "Comparisons between ints where one side is computed" )
 | 
			
		||||
{
 | 
			
		||||
     CHECK( 54 == 6*9 );
 | 
			
		||||
}
 | 
			
		||||
@@ -259,7 +251,7 @@ TEST_CASE( "Comparisons between ints where one side is computed", "" )
 | 
			
		||||
inline const char* returnsConstNull(){ return nullptr; }
 | 
			
		||||
inline char* returnsNull(){ return nullptr; }
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "Pointers can be compared to null", "" )
 | 
			
		||||
TEST_CASE( "Pointers can be compared to null" )
 | 
			
		||||
{
 | 
			
		||||
    TestData* p = nullptr;
 | 
			
		||||
    TestData* pNULL = nullptr;
 | 
			
		||||
@@ -291,7 +283,7 @@ TEST_CASE( "Pointers can be compared to null", "" )
 | 
			
		||||
// is detected and a warning issued.
 | 
			
		||||
// An alternative form of the macros (CHECK_FALSE and REQUIRE_FALSE) can be used instead to capture
 | 
			
		||||
// the operand value.
 | 
			
		||||
TEST_CASE( "'Not' checks that should succeed", "" )
 | 
			
		||||
TEST_CASE( "'Not' checks that should succeed" )
 | 
			
		||||
{
 | 
			
		||||
    bool falseValue = false;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user