mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 19:53:28 +01:00
616 lines
16 KiB
Plaintext
616 lines
16 KiB
Plaintext
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
CatchSelfTest is a <version> host application.
|
|
Run with -? for options
|
|
|
|
-------------------------------------------------------------------------------
|
|
toString(enum)
|
|
-------------------------------------------------------------------------------
|
|
EnumToString.cpp:<line number>
|
|
...............................................................................
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e0) == "0" )
|
|
with expansion:
|
|
"0" == "0"
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e1) == "1" )
|
|
with expansion:
|
|
"1" == "1"
|
|
|
|
-------------------------------------------------------------------------------
|
|
toString(enum w/operator<<)
|
|
-------------------------------------------------------------------------------
|
|
EnumToString.cpp:<line number>
|
|
...............................................................................
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e0) == "E2{0}" )
|
|
with expansion:
|
|
"E2{0}" == "E2{0}"
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e1) == "E2{1}" )
|
|
with expansion:
|
|
"E2{1}" == "E2{1}"
|
|
|
|
-------------------------------------------------------------------------------
|
|
toString(enum class)
|
|
-------------------------------------------------------------------------------
|
|
EnumToString.cpp:<line number>
|
|
...............................................................................
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e0) == "0" )
|
|
with expansion:
|
|
"0" == "0"
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e1) == "1" )
|
|
with expansion:
|
|
"1" == "1"
|
|
|
|
-------------------------------------------------------------------------------
|
|
toString(enum class w/operator<<)
|
|
-------------------------------------------------------------------------------
|
|
EnumToString.cpp:<line number>
|
|
...............................................................................
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e0) == "E2/V0" )
|
|
with expansion:
|
|
"E2/V0" == "E2/V0"
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e1) == "E2/V1" )
|
|
with expansion:
|
|
"E2/V1" == "E2/V1"
|
|
|
|
EnumToString.cpp:<line number>:
|
|
PASSED:
|
|
CHECK( Catch::toString(e3) == "Unknown enum value 10" )
|
|
with expansion:
|
|
"Unknown enum value 10"
|
|
==
|
|
"Unknown enum value 10"
|
|
|
|
-------------------------------------------------------------------------------
|
|
Some simple comparisons between doubles
|
|
-------------------------------------------------------------------------------
|
|
ApproxTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d == Approx( 1.23 ) )
|
|
with expansion:
|
|
1.23 == Approx( 1.23 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d != Approx( 1.22 ) )
|
|
with expansion:
|
|
1.23 != Approx( 1.22 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d != Approx( 1.24 ) )
|
|
with expansion:
|
|
1.23 != Approx( 1.24 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( Approx( d ) == 1.23 )
|
|
with expansion:
|
|
Approx( 1.23 ) == 1.23
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( Approx( d ) != 1.22 )
|
|
with expansion:
|
|
Approx( 1.23 ) != 1.22
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( Approx( d ) != 1.24 )
|
|
with expansion:
|
|
Approx( 1.23 ) != 1.24
|
|
|
|
-------------------------------------------------------------------------------
|
|
Approximate comparisons with different epsilons
|
|
-------------------------------------------------------------------------------
|
|
ApproxTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d != Approx( 1.231 ) )
|
|
with expansion:
|
|
1.23 != Approx( 1.231 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) )
|
|
with expansion:
|
|
1.23 == Approx( 1.231 )
|
|
|
|
-------------------------------------------------------------------------------
|
|
Approximate comparisons with floats
|
|
-------------------------------------------------------------------------------
|
|
ApproxTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 1.23f == Approx( 1.23f ) )
|
|
with expansion:
|
|
1.23f == Approx( 1.2300000191 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 0.0f == Approx( 0.0f ) )
|
|
with expansion:
|
|
0.0f == Approx( 0.0 )
|
|
|
|
-------------------------------------------------------------------------------
|
|
Approximate comparisons with ints
|
|
-------------------------------------------------------------------------------
|
|
ApproxTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 1 == Approx( 1 ) )
|
|
with expansion:
|
|
1 == Approx( 1.0 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 0 == Approx( 0 ) )
|
|
with expansion:
|
|
0 == Approx( 0.0 )
|
|
|
|
-------------------------------------------------------------------------------
|
|
Approximate comparisons with mixed numeric types
|
|
-------------------------------------------------------------------------------
|
|
ApproxTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 1.0f == Approx( 1 ) )
|
|
with expansion:
|
|
1.0f == Approx( 1.0 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 0 == Approx( dZero) )
|
|
with expansion:
|
|
0 == Approx( 0.0 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) )
|
|
with expansion:
|
|
0 == Approx( 0.00001 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( 1.234f == Approx( dMedium ) )
|
|
with expansion:
|
|
1.234f == Approx( 1.234 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( dMedium == Approx( 1.234f ) )
|
|
with expansion:
|
|
1.234 == Approx( 1.2339999676 )
|
|
|
|
-------------------------------------------------------------------------------
|
|
Use a custom approx
|
|
-------------------------------------------------------------------------------
|
|
ApproxTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d == approx( 1.23 ) )
|
|
with expansion:
|
|
1.23 == Approx( 1.23 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d == approx( 1.22 ) )
|
|
with expansion:
|
|
1.23 == Approx( 1.22 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d == approx( 1.24 ) )
|
|
with expansion:
|
|
1.23 == Approx( 1.24 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( d != approx( 1.25 ) )
|
|
with expansion:
|
|
1.23 != Approx( 1.25 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( approx( d ) == 1.23 )
|
|
with expansion:
|
|
Approx( 1.23 ) == 1.23
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( approx( d ) == 1.22 )
|
|
with expansion:
|
|
Approx( 1.23 ) == 1.22
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( approx( d ) == 1.24 )
|
|
with expansion:
|
|
Approx( 1.23 ) == 1.24
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( approx( d ) != 1.25 )
|
|
with expansion:
|
|
Approx( 1.23 ) != 1.25
|
|
|
|
-------------------------------------------------------------------------------
|
|
Approximate PI
|
|
-------------------------------------------------------------------------------
|
|
ApproxTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) )
|
|
with expansion:
|
|
3.1428571429 == Approx( 3.141 )
|
|
|
|
ApproxTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) )
|
|
with expansion:
|
|
3.1428571429 != Approx( 3.141 )
|
|
|
|
-------------------------------------------------------------------------------
|
|
A METHOD_AS_TEST_CASE based test run that succeeds
|
|
-------------------------------------------------------------------------------
|
|
ClassTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ClassTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( s == "hello" )
|
|
with expansion:
|
|
"hello" == "hello"
|
|
|
|
-------------------------------------------------------------------------------
|
|
A METHOD_AS_TEST_CASE based test run that fails
|
|
-------------------------------------------------------------------------------
|
|
ClassTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ClassTests.cpp:<line number>: FAILED:
|
|
REQUIRE( s == "world" )
|
|
with expansion:
|
|
"hello" == "world"
|
|
|
|
-------------------------------------------------------------------------------
|
|
A TEST_CASE_METHOD based test run that succeeds
|
|
-------------------------------------------------------------------------------
|
|
ClassTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ClassTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( m_a == 1 )
|
|
with expansion:
|
|
1 == 1
|
|
|
|
-------------------------------------------------------------------------------
|
|
A TEST_CASE_METHOD based test run that fails
|
|
-------------------------------------------------------------------------------
|
|
ClassTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ClassTests.cpp:<line number>: FAILED:
|
|
REQUIRE( m_a == 2 )
|
|
with expansion:
|
|
1 == 2
|
|
|
|
-------------------------------------------------------------------------------
|
|
Equality checks that should succeed
|
|
-------------------------------------------------------------------------------
|
|
ConditionTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven == 7 )
|
|
with expansion:
|
|
7 == 7
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one == Approx( 9.1f ) )
|
|
with expansion:
|
|
9.1f == Approx( 9.1000003815 )
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.double_pi == Approx( 3.1415926535 ) )
|
|
with expansion:
|
|
3.1415926535 == Approx( 3.1415926535 )
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello == "hello" )
|
|
with expansion:
|
|
"hello" == "hello"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( "hello" == data.str_hello )
|
|
with expansion:
|
|
"hello" == "hello"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello.size() == 5 )
|
|
with expansion:
|
|
5 == 5
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( x == Approx( 1.3 ) )
|
|
with expansion:
|
|
1.3 == Approx( 1.3 )
|
|
|
|
-------------------------------------------------------------------------------
|
|
Equality checks that should fail
|
|
-------------------------------------------------------------------------------
|
|
ConditionTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ConditionTests.cpp:<line number>: FAILED:
|
|
CHECK( data.int_seven == 6 )
|
|
with expansion:
|
|
7 == 6
|
|
|
|
ConditionTests.cpp:<line number>: FAILED:
|
|
CHECK( data.int_seven == 8 )
|
|
with expansion:
|
|
7 == 8
|
|
|
|
-------------------------------------------------------------------------------
|
|
Inequality checks that should succeed
|
|
-------------------------------------------------------------------------------
|
|
ConditionTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven != 6 )
|
|
with expansion:
|
|
7 != 6
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven != 8 )
|
|
with expansion:
|
|
7 != 8
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one != Approx( 9.11f ) )
|
|
with expansion:
|
|
9.1f != Approx( 9.1099996567 )
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one != Approx( 9.0f ) )
|
|
with expansion:
|
|
9.1f != Approx( 9.0 )
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one != Approx( 1 ) )
|
|
with expansion:
|
|
9.1f != Approx( 1.0 )
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one != Approx( 0 ) )
|
|
with expansion:
|
|
9.1f != Approx( 0.0 )
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.double_pi != Approx( 3.1415 ) )
|
|
with expansion:
|
|
3.1415926535 != Approx( 3.1415 )
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello != "goodbye" )
|
|
with expansion:
|
|
"hello" != "goodbye"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello != "hell" )
|
|
with expansion:
|
|
"hello" != "hell"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello != "hello1" )
|
|
with expansion:
|
|
"hello" != "hello1"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello.size() != 6 )
|
|
with expansion:
|
|
5 != 6
|
|
|
|
-------------------------------------------------------------------------------
|
|
Inequality checks that should fail
|
|
-------------------------------------------------------------------------------
|
|
ConditionTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ConditionTests.cpp:<line number>: FAILED:
|
|
CHECK( data.int_seven != 7 )
|
|
with expansion:
|
|
7 != 7
|
|
|
|
ConditionTests.cpp:<line number>: FAILED:
|
|
CHECK( data.float_nine_point_one != Approx( 9.1f ) )
|
|
with expansion:
|
|
9.1f != Approx( 9.1000003815 )
|
|
|
|
-------------------------------------------------------------------------------
|
|
Ordering comparison checks that should succeed
|
|
-------------------------------------------------------------------------------
|
|
ConditionTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven < 8 )
|
|
with expansion:
|
|
7 < 8
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven > 6 )
|
|
with expansion:
|
|
7 > 6
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven > 0 )
|
|
with expansion:
|
|
7 > 0
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven > -1 )
|
|
with expansion:
|
|
7 > -1
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven >= 7 )
|
|
with expansion:
|
|
7 >= 7
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven >= 6 )
|
|
with expansion:
|
|
7 >= 6
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven <= 7 )
|
|
with expansion:
|
|
7 <= 7
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.int_seven <= 8 )
|
|
with expansion:
|
|
7 <= 8
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one > 9 )
|
|
with expansion:
|
|
9.1f > 9
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one < 10 )
|
|
with expansion:
|
|
9.1f < 10
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.float_nine_point_one < 9.2 )
|
|
with expansion:
|
|
9.1f < 9.2
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello <= "hello" )
|
|
with expansion:
|
|
"hello" <= "hello"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello >= "hello" )
|
|
with expansion:
|
|
"hello" >= "hello"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello < "hellp" )
|
|
with expansion:
|
|
"hello" < "hellp"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello < "zebra" )
|
|
with expansion:
|
|
"hello" < "zebra"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello > "hellm" )
|
|
with expansion:
|
|
"hello" > "hellm"
|
|
|
|
ConditionTests.cpp:<line number>:
|
|
PASSED:
|
|
REQUIRE( data.str_hello > "a" )
|
|
with expansion:
|
|
"hello" > "a"
|
|
|
|
-------------------------------------------------------------------------------
|
|
Ordering comparison checks that should fail
|
|
-------------------------------------------------------------------------------
|
|
ConditionTests.cpp:<line number>
|
|
...............................................................................
|
|
|
|
ConditionTests.cpp:<line number>: FAILED:
|
|
CHECK( data.int_seven > 7 )
|
|
with expansion:
|
|
7 > 7
|
|
|
|
ConditionTests.cpp:<line number>: FAILED:
|
|
CHECK( data.int_seven < 7 )
|
|
with expansion:
|
|
7 < 7
|
|
|
|
===============================================================================
|
|
test cases: 21 | 16 passed | 3 failed | 2 failed as expected
|
|
assertions: 81 | 73 passed | 4 failed | 4 failed as expected
|
|
|