mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Merge pull request #1769 from amitherman95/amitherman-1767
Patch:Failure to pass special chars through input file
This commit is contained in:
commit
1c5749669e
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "catch_test_spec_parser.h"
|
#include "catch_test_spec_parser.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}
|
TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}
|
||||||
@ -18,6 +19,7 @@ namespace Catch {
|
|||||||
m_escapeChars.clear();
|
m_escapeChars.clear();
|
||||||
m_substring.reserve(m_arg.size());
|
m_substring.reserve(m_arg.size());
|
||||||
m_patternName.reserve(m_arg.size());
|
m_patternName.reserve(m_arg.size());
|
||||||
|
m_realPatternPos = 0;
|
||||||
for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
|
for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
|
||||||
visitChar( m_arg[m_pos] );
|
visitChar( m_arg[m_pos] );
|
||||||
endMode();
|
endMode();
|
||||||
@ -32,6 +34,7 @@ namespace Catch {
|
|||||||
escape();
|
escape();
|
||||||
m_substring += c;
|
m_substring += c;
|
||||||
m_patternName += c;
|
m_patternName += c;
|
||||||
|
m_realPatternPos++;
|
||||||
return;
|
return;
|
||||||
}else if((m_mode != EscapedName) && (c == ',') ) {
|
}else if((m_mode != EscapedName) && (c == ',') ) {
|
||||||
endMode();
|
endMode();
|
||||||
@ -49,7 +52,10 @@ namespace Catch {
|
|||||||
break;
|
break;
|
||||||
case EscapedName:
|
case EscapedName:
|
||||||
endMode();
|
endMode();
|
||||||
break;
|
m_substring += c;
|
||||||
|
m_patternName += c;
|
||||||
|
m_realPatternPos++;
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
case Tag:
|
case Tag:
|
||||||
case QuotedName:
|
case QuotedName:
|
||||||
@ -59,8 +65,10 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_substring += c;
|
m_substring += c;
|
||||||
if( !isControlChar( c ) )
|
if( !isControlChar( c ) ) {
|
||||||
m_patternName += c;
|
m_patternName += c;
|
||||||
|
m_realPatternPos++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Two of the processing methods return true to signal the caller to return
|
// Two of the processing methods return true to signal the caller to return
|
||||||
// without adding the given character to the current pattern strings
|
// without adding the given character to the current pattern strings
|
||||||
@ -119,7 +127,7 @@ namespace Catch {
|
|||||||
void TestSpecParser::escape() {
|
void TestSpecParser::escape() {
|
||||||
saveLastMode();
|
saveLastMode();
|
||||||
m_mode = EscapedName;
|
m_mode = EscapedName;
|
||||||
m_escapeChars.push_back( m_pos );
|
m_escapeChars.push_back(m_realPatternPos);
|
||||||
}
|
}
|
||||||
bool TestSpecParser::isControlChar( char c ) const {
|
bool TestSpecParser::isControlChar( char c ) const {
|
||||||
switch( m_mode ) {
|
switch( m_mode ) {
|
||||||
|
@ -25,6 +25,7 @@ namespace Catch {
|
|||||||
Mode lastMode = None;
|
Mode lastMode = None;
|
||||||
bool m_exclusion = false;
|
bool m_exclusion = false;
|
||||||
std::size_t m_pos = 0;
|
std::size_t m_pos = 0;
|
||||||
|
std::size_t m_realPatternPos = 0;
|
||||||
std::string m_arg;
|
std::string m_arg;
|
||||||
std::string m_substring;
|
std::string m_substring;
|
||||||
std::string m_patternName;
|
std::string m_patternName;
|
||||||
|
@ -433,6 +433,12 @@ set_tests_properties(FilenameAsTagsTest PROPERTIES PASS_REGULAR_EXPRESSION "\\[#
|
|||||||
add_test(NAME EscapeSpecialCharactersInTestNames COMMAND $<TARGET_FILE:SelfTest> "Test with special\\, characters \"in name")
|
add_test(NAME EscapeSpecialCharactersInTestNames COMMAND $<TARGET_FILE:SelfTest> "Test with special\\, characters \"in name")
|
||||||
set_tests_properties(EscapeSpecialCharactersInTestNames PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
|
set_tests_properties(EscapeSpecialCharactersInTestNames PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
|
||||||
|
|
||||||
|
add_test(NAME SpecialCharactersInTestNamesFromFile COMMAND $<TARGET_FILE:SelfTest> "-f ${CATCH_DIR}/projects/SelfTest/Misc/special-characters-in-file.input")
|
||||||
|
set_tests_properties(SpecialCharactersInTestNamesFromFile PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
|
||||||
|
|
||||||
|
add_test(NAME RunningTestsFromFile COMMAND $<TARGET_FILE:SelfTest> "-f ${CATCH_DIR}/projects/SelfTest/Misc/plain-old-tests.input")
|
||||||
|
set_tests_properties(RunningTestsFromFile PROPERTIES PASS_REGULAR_EXPRESSION "6 assertions in 2 test cases")
|
||||||
|
|
||||||
|
|
||||||
if (CATCH_USE_VALGRIND)
|
if (CATCH_USE_VALGRIND)
|
||||||
add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)
|
add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)
|
||||||
|
2
projects/SelfTest/Misc/plain-old-tests.input
Normal file
2
projects/SelfTest/Misc/plain-old-tests.input
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
random SECTION tests
|
||||||
|
nested SECTION tests
|
1
projects/SelfTest/Misc/special-characters-in-file.input
Normal file
1
projects/SelfTest/Misc/special-characters-in-file.input
Normal file
@ -0,0 +1 @@
|
|||||||
|
Test with special\, characters \"in name
|
Loading…
Reference in New Issue
Block a user