-
Notifications
You must be signed in to change notification settings - Fork 97
refactor: Enforce arrayRef regex & Handling and XML Spacing Rules #3900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
abe634c
e03d340
dc6c48f
b015667
d237499
77c7b3e
ff77135
e8be705
b89c41a
071b15c
95710e3
f2724e4
e53891a
c5513f4
1a51f53
05c7ae1
332370c
3dafc57
768a9cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,6 +243,9 @@ INSTANTIATE_TEST_SUITE_P( | |
| real64AttributeTests, | ||
| real64AttributeTestFixture, | ||
| ::testing::Values( std::make_tuple( "1", 1, false ), | ||
| std::make_tuple( "1 ", 1, false ), | ||
| std::make_tuple( " 1", 1, false ), | ||
| std::make_tuple( " 1 ", 1, false ), | ||
| std::make_tuple( "-23", -23, false ), | ||
| std::make_tuple( "4.5", 4.5, false ), | ||
| std::make_tuple( "4.", 4.0, false ), | ||
|
|
@@ -260,7 +263,6 @@ INSTANTIATE_TEST_SUITE_P( | |
| std::make_tuple( "1.234gamma", 0, true ), | ||
| std::make_tuple( "1.2.3", 0, true ), | ||
| std::make_tuple( "1e2.3 ", 0, true ), | ||
| std::make_tuple( "1 ", 0, true ), | ||
| std::make_tuple( "1e", 0, true ), | ||
| std::make_tuple( "1e-", 0, true ), | ||
| std::make_tuple( "1e+", 0, true ))); | ||
|
|
@@ -284,6 +286,9 @@ INSTANTIATE_TEST_SUITE_P( | |
| real32AttributeTests, | ||
| real32AttributeTestFixture, | ||
| ::testing::Values( std::make_tuple( "1", 1, false ), | ||
| std::make_tuple( "1 ", 1, false ), | ||
| std::make_tuple( " 1", 1, false ), | ||
| std::make_tuple( " 1 ", 1, false ), | ||
| std::make_tuple( "-23", -23, false ), | ||
| std::make_tuple( "4.5", 4.5, false ), | ||
| std::make_tuple( "4.", 4.0, false ), | ||
|
|
@@ -301,7 +306,6 @@ INSTANTIATE_TEST_SUITE_P( | |
| std::make_tuple( "1.234gamma", 0, true ), | ||
| std::make_tuple( "1.2.3", 0, true ), | ||
| std::make_tuple( "1e2.3 ", 0, true ), | ||
| std::make_tuple( "1 ", 0, true ), | ||
| std::make_tuple( "1e", 0, true ), | ||
|
Comment on lines
308
to
309
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why removing that case instead of adding one to test your new feature? (space before)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the regex has been updated this case no longer works
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since your last commit, it is not prohibed nor accepted. |
||
| std::make_tuple( "1e-", 0, true ), | ||
| std::make_tuple( "1e+", 0, true ))); | ||
|
|
@@ -319,13 +323,15 @@ INSTANTIATE_TEST_SUITE_P( | |
| integerAttributeTests, | ||
| integerAttributeTestFixture, | ||
| ::testing::Values( std::make_tuple( "1", 1, false ), | ||
| std::make_tuple( "1 ", 1, false ), | ||
| std::make_tuple( " 1", 1, false ), | ||
| std::make_tuple( " 1 ", 1, false ), | ||
| std::make_tuple( "-23", -23, false ), | ||
| std::make_tuple( "4.5", 0, true ), | ||
| std::make_tuple( "4.", 0, true ), | ||
| std::make_tuple( "alpha", 0, true ), | ||
| std::make_tuple( "1beta234", 0, true ), | ||
| std::make_tuple( "1234gamma", 0, true ), | ||
| std::make_tuple( "1 ", 0, true ), | ||
| std::make_tuple( "1 2", 0, true ))); | ||
|
|
||
|
|
||
|
|
@@ -374,12 +380,16 @@ TEST( testXmlWrapper, testGroupNamesFormats ) | |
| GroupNameTest( groupNameRegex, "testname01" ), | ||
| GroupNameTest( groupNameRegex, "test_name" ), | ||
| GroupNameTest( groupNameRegex, "test-name" ), | ||
| GroupNameTest( groupNameRegex, "test.name" ), | ||
| GroupNameTest( groupNameRegex, " testname " ), | ||
| GroupNameTest( groupNameRegex, " \t testname \n " ), | ||
| }; | ||
| for( GroupNameTest const & input : workingInputs ) | ||
| { | ||
| EXPECT_NO_THROW( xmlWrapper::stringToInputVariable( groupName, input.m_valueToTest, input.m_regex ) ); | ||
| EXPECT_STREQ( input.m_valueToTest.c_str(), groupName.c_str() ); | ||
| std::string groupNameComp; | ||
| std::istringstream ss( input.m_valueToTest ); | ||
| ss >> groupNameComp >> std::ws; | ||
| EXPECT_STREQ( groupNameComp.c_str(), groupName.c_str() ); | ||
|
Comment on lines
+389
to
+392
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please revert |
||
| } | ||
| } | ||
| { | ||
|
|
@@ -391,8 +401,6 @@ TEST( testXmlWrapper, testGroupNamesFormats ) | |
| //white spaces | ||
| GroupNameTest( groupNameRegex, "test name" ), | ||
| GroupNameTest( groupNameRegex, "test\tname" ), | ||
| GroupNameTest( groupNameRegex, "testname " ), | ||
| GroupNameTest( groupNameRegex, " testname" ), | ||
| //fordbiden characters | ||
| GroupNameTest( groupNameRegex, "test/name" ), | ||
| GroupNameTest( groupNameRegex, "test:name" ), | ||
|
|
@@ -407,6 +415,93 @@ TEST( testXmlWrapper, testGroupNamesFormats ) | |
| } | ||
| } | ||
| } | ||
| TEST( testXmlWrapper, testGroupNamesArrayFormats ) | ||
| { | ||
| struct GroupNameTest | ||
| { | ||
| Regex const & m_regex; | ||
| string m_valueToTest; | ||
| GroupNameTest( Regex const & regex, string_view valueToTest ): | ||
| m_regex( regex ), m_valueToTest( valueToTest ) {} | ||
| }; | ||
|
|
||
| Regex const & groupNameRefArrayRegex = rtTypes::getTypeRegex< string >( rtTypes::CustomTypes::groupNameRefArray ); | ||
| string groupName; | ||
|
|
||
| { | ||
| stdVector< GroupNameTest > workingInputs = { | ||
| GroupNameTest( groupNameRefArrayRegex, "{}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, " {} " ), | ||
| GroupNameTest( groupNameRefArrayRegex, " \t {} \n " ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{groupName}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{123name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{name123}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{a-Z0-9./*[]-_,}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{name.with-special_chars}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{path/to/resource*}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{[arrayElement]}" ), | ||
|
Comment on lines
+441
to
+442
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add these ones in non-array |
||
| GroupNameTest( groupNameRefArrayRegex, "{name1,name2,name3}" ), | ||
| }; | ||
| for( GroupNameTest const & input : workingInputs ) | ||
| { | ||
| EXPECT_NO_THROW( xmlWrapper::stringToInputVariable( groupName, input.m_valueToTest, input.m_regex ) ); | ||
| std::string groupNameComp; | ||
| std::istringstream ss( input.m_valueToTest ); | ||
| ss >> groupNameComp >> std::ws; | ||
| EXPECT_STREQ( groupNameComp.c_str(), groupName.c_str() ); | ||
| } | ||
| } | ||
| { | ||
| stdVector< GroupNameTest > erroneousInputs = { | ||
| GroupNameTest( groupNameRefArrayRegex, "" ), | ||
| GroupNameTest( groupNameRefArrayRegex, " " ), | ||
| GroupNameTest( groupNameRefArrayRegex, " \t " ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{\t}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test:name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test;name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test\\name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test|name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test^name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test$name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test&name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test#name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test!name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test%name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test@name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test(name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test)name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test=name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test+name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test<name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test>name}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test\tname}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test\nname}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{test\rname}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "groupName" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{groupName" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "groupName}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{groupName}} " ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{}groupName" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "groupName{}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{hello, \t\n\r ,world}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "test{groupName}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{groupName}test" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{groupName} test" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{element with space, another}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{element, element with space, 123.456, a-b}" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{ space at ends } " ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{valuewith,,commas }" ), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add one with all alowed whitespaces kind in-between the commas ( |
||
| GroupNameTest( groupNameRefArrayRegex, "{ value with , commas }" ), | ||
| GroupNameTest( groupNameRefArrayRegex, "{{groupname}}" ), | ||
| }; | ||
| for( GroupNameTest const & input : erroneousInputs ) | ||
| { | ||
| EXPECT_THROW( xmlWrapper::stringToInputVariable( groupName, input.m_valueToTest, input.m_regex ), | ||
| InputError ) << "Parsing input '"<< input.m_valueToTest | ||
| << "' with regex '" << input.m_regex.m_regexStr << "' didn't throw an InputError as expected."; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| int main( int argc, char * argv[] ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.