mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Cleaned tests up a bit
This commit is contained in:
parent
293e54dcbe
commit
4b99be6a9a
@ -343,134 +343,142 @@ TEST_CASE( "PartTracker" ) {
|
|||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
|
|
||||||
IPartTracker& testCase = SectionTracker::acquire( ctx, "Testcase" );
|
IPartTracker& testCase = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase.isOpen() );
|
||||||
|
|
||||||
IPartTracker& s1 = SectionTracker::acquire( ctx, "S1" );
|
IPartTracker& s1 = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1.isOpen() == true );
|
REQUIRE( s1.isOpen() );
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
|
||||||
|
|
||||||
SECTION( "successfully close one section" ) {
|
SECTION( "successfully close one section" ) {
|
||||||
s1.close();
|
s1.close();
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == true );
|
REQUIRE( s1.isSuccessfullyCompleted() );
|
||||||
REQUIRE( testCase.hasEnded() == false );
|
REQUIRE( testCase.hasEnded() == false );
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( ctx.completedCycle() == true );
|
REQUIRE( ctx.completedCycle() );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == true );
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "fail one section" ) {
|
SECTION( "fail one section" ) {
|
||||||
s1.fail();
|
s1.fail();
|
||||||
|
REQUIRE( s1.hasEnded() );
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
||||||
REQUIRE( s1.hasEnded() == true );
|
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
|
||||||
REQUIRE( testCase.hasEnded() == false );
|
REQUIRE( testCase.hasEnded() == false );
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( ctx.completedCycle() == true );
|
REQUIRE( ctx.completedCycle() );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
SECTION( "re-enter after failed section" ) {
|
SECTION( "re-enter after failed section" ) {
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() == false );
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( ctx.completedCycle() == true );
|
REQUIRE( ctx.completedCycle() );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == true );
|
REQUIRE( testCase.hasEnded() );
|
||||||
REQUIRE( testCase.hasEnded() == true );
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
SECTION( "re-enter after failed section and find next section" ) {
|
SECTION( "re-enter after failed section and find next section" ) {
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isSuccessfullyCompleted() == false );
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2.isOpen() );
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
s2.close();
|
s2.close();
|
||||||
REQUIRE( ctx.completedCycle() == true );
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == true );
|
REQUIRE( testCase.hasEnded() );
|
||||||
REQUIRE( testCase.hasEnded() == true );
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "successfully close one section, then find another" ) {
|
SECTION( "successfully close one section, then find another" ) {
|
||||||
s1.close();
|
s1.close();
|
||||||
REQUIRE( ctx.completedCycle() == true );
|
|
||||||
|
|
||||||
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2.isOpen() == false );
|
REQUIRE( s2.isOpen() == false );
|
||||||
REQUIRE( s2.isSuccessfullyCompleted() == false );
|
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase.hasEnded() == false );
|
||||||
|
|
||||||
SECTION( "Re-enter - skips S1 and enters S2" ) {
|
SECTION( "Re-enter - skips S1 and enters S2" ) {
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase2.isOpen() );
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
|
||||||
|
|
||||||
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() == false );
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
IPartTracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
IPartTracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2b.isOpen() );
|
REQUIRE( s2b.isOpen() );
|
||||||
REQUIRE( s2b.isSuccessfullyCompleted() == false );
|
|
||||||
|
|
||||||
REQUIRE( ctx.completedCycle() == false );
|
REQUIRE( ctx.completedCycle() == false );
|
||||||
|
|
||||||
SECTION ("Successfully close S2") {
|
SECTION ("Successfully close S2") {
|
||||||
s2b.close();
|
s2b.close();
|
||||||
REQUIRE( ctx.completedCycle() == true );
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
REQUIRE( s2b.isSuccessfullyCompleted() == true );
|
REQUIRE( s2b.isSuccessfullyCompleted() );
|
||||||
REQUIRE( testCase2.hasEnded() == false );
|
REQUIRE( testCase2.hasEnded() == false );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == true );
|
REQUIRE( testCase2.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
SECTION ("fail S2") {
|
SECTION ("fail S2") {
|
||||||
s2b.fail();
|
s2b.fail();
|
||||||
REQUIRE( ctx.completedCycle() == true );
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
|
REQUIRE( s2b.hasEnded() );
|
||||||
REQUIRE( s2b.isSuccessfullyCompleted() == false );
|
REQUIRE( s2b.isSuccessfullyCompleted() == false );
|
||||||
REQUIRE( s2b.hasEnded() == true );
|
|
||||||
REQUIRE( testCase2.hasEnded() == false );
|
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
|
// Need a final cycle
|
||||||
|
ctx.startCycle();
|
||||||
|
IPartTracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase3.isOpen() );
|
||||||
|
|
||||||
|
IPartTracker& s1c = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1c.isOpen() == false );
|
||||||
|
|
||||||
|
IPartTracker& s2c = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2c.isOpen() == false );
|
||||||
|
|
||||||
|
testCase3.close();
|
||||||
|
REQUIRE( testCase3.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "open a nested section" ) {
|
SECTION( "open a nested section" ) {
|
||||||
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2.isOpen() == true );
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
s2.close();
|
s2.close();
|
||||||
REQUIRE( s2.isSuccessfullyCompleted() == true );
|
REQUIRE( s2.isSuccessfullyCompleted() );
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
s1.close();
|
s1.close();
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == true );
|
REQUIRE( s1.isSuccessfullyCompleted() );
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
testCase.close();
|
testCase.close();
|
||||||
REQUIRE( testCase.isSuccessfullyCompleted() == true );
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "start a generator" ) {
|
SECTION( "start a generator" ) {
|
||||||
IndexTracker& g1 = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1 = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1.isOpen() == true );
|
REQUIRE( g1.isOpen() );
|
||||||
REQUIRE( g1.index() == 0 );
|
REQUIRE( g1.index() == 0 );
|
||||||
|
|
||||||
REQUIRE( g1.isSuccessfullyCompleted() == false );
|
REQUIRE( g1.isSuccessfullyCompleted() == false );
|
||||||
@ -486,31 +494,31 @@ TEST_CASE( "PartTracker" ) {
|
|||||||
SECTION( "Re-enter for second generation" ) {
|
SECTION( "Re-enter for second generation" ) {
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isOpen() == true );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isOpen() == true );
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
|
|
||||||
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1b.isOpen() == true );
|
REQUIRE( g1b.isOpen() );
|
||||||
REQUIRE( g1b.index() == 1 );
|
REQUIRE( g1b.index() == 1 );
|
||||||
|
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
s1b.close();
|
s1b.close();
|
||||||
REQUIRE( s1b.isSuccessfullyCompleted() == true );
|
REQUIRE( s1b.isSuccessfullyCompleted() );
|
||||||
REQUIRE( g1b.isSuccessfullyCompleted() == true );
|
REQUIRE( g1b.isSuccessfullyCompleted() );
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == true );
|
REQUIRE( testCase2.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SECTION( "Start a new inner section" ) {
|
SECTION( "Start a new inner section" ) {
|
||||||
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
IPartTracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2.isOpen() == true );
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
s2.close();
|
s2.close();
|
||||||
REQUIRE( s2.isSuccessfullyCompleted() == true );
|
REQUIRE( s2.isSuccessfullyCompleted() );
|
||||||
|
|
||||||
s1.close();
|
s1.close();
|
||||||
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
||||||
@ -521,29 +529,29 @@ TEST_CASE( "PartTracker" ) {
|
|||||||
SECTION( "Re-enter for second generation" ) {
|
SECTION( "Re-enter for second generation" ) {
|
||||||
ctx.startCycle();
|
ctx.startCycle();
|
||||||
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
IPartTracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
IPartTracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
REQUIRE( s1b.isSuccessfullyCompleted() == false );
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
// generator - next value
|
// generator - next value
|
||||||
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
REQUIRE( g1b.isOpen() == true );
|
REQUIRE( g1b.isOpen() );
|
||||||
REQUIRE( g1b.index() == 1 );
|
REQUIRE( g1b.index() == 1 );
|
||||||
|
|
||||||
// inner section again
|
// inner section again
|
||||||
IPartTracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
IPartTracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
||||||
REQUIRE( s2b.isOpen() == true );
|
REQUIRE( s2b.isOpen() );
|
||||||
|
|
||||||
s2b.close();
|
s2b.close();
|
||||||
REQUIRE( s2b.isSuccessfullyCompleted() == true );
|
REQUIRE( s2b.isSuccessfullyCompleted() );
|
||||||
|
|
||||||
s1b.close();
|
s1b.close();
|
||||||
REQUIRE( s1b.isSuccessfullyCompleted() == true );
|
REQUIRE( s1b.isSuccessfullyCompleted() );
|
||||||
REQUIRE( g1b.isSuccessfullyCompleted() == true );
|
REQUIRE( g1b.isSuccessfullyCompleted() );
|
||||||
|
|
||||||
testCase2.close();
|
testCase2.close();
|
||||||
REQUIRE( testCase2.isSuccessfullyCompleted() == true );
|
REQUIRE( testCase2.isSuccessfullyCompleted() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// !TBD"
|
// !TBD"
|
||||||
|
Loading…
Reference in New Issue
Block a user