Ignore leading/trailing whitespace in test/section specs

The leading/trailing whitespace is problematic because of e.g.
`WHEN` macro having preceeding whitespace for alignment, and it is
generally messy.

Credits to Phil who did lot of the original work.

Closes #1708
This commit is contained in:
Martin Hořeňovský 2019-09-09 11:30:45 +02:00
parent a156440b19
commit af8b2538a6
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
12 changed files with 219 additions and 27 deletions

View file

@ -262,7 +262,24 @@ TEST_CASE( "Parse test names and tags" ) {
CHECK( spec.matches( tcC ) == false );
CHECK( spec.matches( tcD ) == true );
}
SECTION( "Leading and trailing spaces in test spec" ) {
TestSpec spec = parseTestSpec( "\" aardvark \"" );
CHECK( spec.matches( fakeTestCase( " aardvark " ) ) );
CHECK( spec.matches( fakeTestCase( " aardvark" ) ) );
CHECK( spec.matches( fakeTestCase( " aardvark " ) ) );
CHECK( spec.matches( fakeTestCase( "aardvark " ) ) );
CHECK( spec.matches( fakeTestCase( "aardvark" ) ) );
}
SECTION( "Leading and trailing spaces in test name" ) {
TestSpec spec = parseTestSpec( "aardvark" );
CHECK( spec.matches( fakeTestCase( " aardvark " ) ) );
CHECK( spec.matches( fakeTestCase( " aardvark" ) ) );
CHECK( spec.matches( fakeTestCase( " aardvark " ) ) );
CHECK( spec.matches( fakeTestCase( "aardvark " ) ) );
CHECK( spec.matches( fakeTestCase( "aardvark" ) ) );
}
}
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {