Browse Source

Add backslash as valid character for SP file value

Patrick-Christopher 11 months ago
parent
commit
bd26893f46

+ 1 - 1
README.md

@@ -34,7 +34,7 @@ A __Date__ class comes with this submodule, which you can use to represent a dat
 
 #### Features ####
 
-- none
+- Section Pair values now support backslash characters, which are common on Windows to describe a file path
 
 #### Improvements ####
 

+ 2 - 2
source/ls-std/io/section-pair/validator/SectionPairValueValidator.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-09
-* Changed:         2023-04-13
+* Changed:         2023-06-06
 *
 * */
 
@@ -40,6 +40,6 @@ bool SectionPairValueValidator::isValid()
 
 string SectionPairValueValidator::_getValidationRegex()
 {
-  string value = R"([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512})";
+  string value = R"([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512})";
   return value;
 }

+ 2 - 2
test/cases/io/section-pair/evaluator/SectionPairValueArgumentEvaluatorTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-10
-* Changed:         2023-05-18
+* Changed:         2023-06-06
 *
 * */
 
@@ -65,5 +65,5 @@ namespace
         IllegalArgumentException);
   }
 
-  INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest, Values("=33", "\\empty"));
+  INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairValueArgumentEvaluatorTest_InvalidArgumentTest, Values("=33"));
 }

+ 2 - 2
test/cases/io/section-pair/validator/SectionPairDocumentValidatorTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-21
-* Changed:         2023-03-25
+* Changed:         2023-06-06
 *
 * */
 
@@ -77,5 +77,5 @@ namespace
 
   INSTANTIATE_TEST_SUITE_P(LineBreakTest, SectionPairDocumentValidatorTest_LineBreakTest, Values(SectionPairDocumentProvider::createSerializedDocument(NewLine::getWindowsNewLine()), SectionPairDocumentProvider::createSerializedDocument(NewLine::getUnixNewLine())));
   INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairDocumentValidatorTest_InvalidArgumentTest, Values("\n[general]\n\ncolors:\nblue\n"));
-  INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairDocumentValidatorTest_ValidArgumentTest, Values(SectionPairDocumentProvider::createSerializedDocumentComputerExample(NewLine::get())));
+  INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairDocumentValidatorTest_ValidArgumentTest, Values(SectionPairDocumentProvider::createSerializedDocumentComputerExample(NewLine::get()), SectionPairDocumentProvider::createSerializedDocumentColineExample(NewLine::get())));
 }

+ 2 - 3
test/cases/io/section-pair/validator/SectionPairRowListValueValidatorTest.cpp

@@ -3,12 +3,11 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-19
-* Changed:         2023-04-13
+* Changed:         2023-06-06
 *
 * */
 
 #include <gtest/gtest.h>
-#include <ls-std/ls-std-core.hpp>
 #include <ls-std/ls-std-io.hpp>
 #include <string>
 
@@ -51,7 +50,7 @@ namespace
 
   TEST_F(SectionPairRowListValueValidatorTest, getValidationRegex)
   {
-    string expected = R"(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*)))";
+    string expected = R"(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*)))";
     string actual = SectionPairRowListValueValidator::getValidationRegex();
 
     ASSERT_STREQ(expected.c_str(), actual.c_str());

+ 2 - 2
test/cases/io/section-pair/validator/SectionPairRowSingleValueValidatorTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-19
-* Changed:         2023-04-13
+* Changed:         2023-06-06
 *
 * */
 
@@ -52,7 +52,7 @@ namespace
 
   TEST_F(SectionPairRowSingleValueValidatorTest, getValidationRegex)
   {
-    string expected = R"(([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))";
+    string expected = R"(([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))";
     ASSERT_STREQ(expected.c_str(), SectionPairRowSingleValueValidator::getValidationRegex().c_str());
   }
 

+ 2 - 2
test/cases/io/section-pair/validator/SectionPairRowValidatorTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-20
-* Changed:         2023-04-13
+* Changed:         2023-06-06
 *
 * */
 
@@ -51,7 +51,7 @@ namespace
 
   TEST_F(SectionPairRowValidatorTest, getValidationRegex)
   {
-    string expected = R"((([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))|(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*))))";
+    string expected = R"((([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))|(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*))))";
     ASSERT_STREQ(expected.c_str(), SectionPairRowValidator::getValidationRegex().c_str());
   }
 

+ 2 - 2
test/cases/io/section-pair/validator/SectionPairSectionValidatorTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-20
-* Changed:         2023-04-13
+* Changed:         2023-06-06
 *
 * */
 
@@ -55,7 +55,7 @@ namespace
   TEST_F(SectionPairSectionValidatorTest, getValidationRegex)
   {
     string expected =
-        R"(((\n)|(\r\n))\[{1}([a-z]([a-z0-9-]){1,63})\]{1}(((\n)|(\r\n)){2})(((([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))|(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*)))){1})(((([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))|(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*))))*))";
+        R"(((\n)|(\r\n))\[{1}([a-z]([a-z0-9-]){1,63})\]{1}(((\n)|(\r\n)){2})(((([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))|(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*)))){1})(((([a-z]([a-z0-9-]){1,63})={1}([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}){1}($|\n{1}|\r{1}\n{1}))|(((((([a-z]([a-z0-9-]){1,63}):{1})((\n{1})|(\r{1}\n{1})))( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))){1}(( {2}[a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512}((\n{1})|(\r{1}\n{1})))*))))*))";
     ASSERT_STREQ(expected.c_str(), SectionPairSectionValidator::getValidationRegex().c_str());
   }
 

+ 3 - 3
test/cases/io/section-pair/validator/SectionPairValueValidatorTest.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-09
-* Changed:         2023-04-13
+* Changed:         2023-06-06
 *
 * */
 
@@ -52,7 +52,7 @@ namespace
 
   TEST_F(SectionPairValueValidatorTest, getValidationRegex)
   {
-    string expected = R"([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$ۤ<>+:;., \*\/"]{1,512})";
+    string expected = R"([a-zA-Z0-9\-_#!?\[\]\{\}\(\)\$€\\§<>+:;., \*\/"]{1,512})";
     string actual = SectionPairValueValidator::getValidationRegex();
 
     ASSERT_STREQ(expected.c_str(), actual.c_str());
@@ -69,5 +69,5 @@ namespace
   }
 
   INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairValueValidatorTest_ValidArgumentTest, Values("blue is my favourite color!", "Age", "Tom", "\"Tom\"", "Hello!" + NewLine::getUnixNewLine(), "Hello!" + NewLine::getWindowsNewLine()));
-  INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairValueValidatorTest_InvalidArgumentTest, Values("1+2=3", "\\escape"));
+  INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairValueValidatorTest_InvalidArgumentTest, Values("1+2=3"));
 }

+ 22 - 1
test/classes/io/section-pair/SectionPairDocumentProvider.cpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-16
-* Changed:         2023-05-16
+* Changed:         2023-06-06
 *
 * */
 
@@ -12,6 +12,7 @@
 #include <ls-std/ls-std-io.hpp>
 
 using ls::std::core::type::byte_field;
+using ls::std::io::NewLine;
 using ls::std::io::SectionPairDocument;
 using ls::std::io::SectionPairRow;
 using ls::std::io::SectionPairRowEnumType;
@@ -76,6 +77,26 @@ byte_field SectionPairDocumentProvider::createSerializedDocument(const string &_
   return serializedDocument;
 }
 
+byte_field SectionPairDocumentProvider::createSerializedDocumentColineExample(const string &_newLine)
+{
+  string paragraph = _newLine + _newLine;
+  string _resourcesFolderLocation = R"lit(C:\Users\Admin\CLionProjects\coline-documentation\test\resources)lit";
+
+  byte_field fileContent = "# section-pair document" + paragraph;
+  fileContent += "[general]" + paragraph;
+  fileContent += "name=Lynar Studios - Standard Library" + _newLine;
+  fileContent += "version=2023.2.0" + paragraph;
+  fileContent += "[input]" + paragraph;
+  fileContent += "directories:" + _newLine;
+  fileContent += "  " + _resourcesFolderLocation + "source" + _newLine;
+  fileContent += "extensions:" + _newLine;
+  fileContent += "  .cpp" + paragraph;
+  fileContent += "[output]" + paragraph;
+  fileContent += "directory=" + _resourcesFolderLocation + "doc" + _newLine;
+
+  return fileContent;
+}
+
 byte_field SectionPairDocumentProvider::createSerializedDocumentComputerExample(const string &_newLine)
 {
   byte_field serializedDocument = "# section-pair document" + _newLine;

+ 2 - 1
test/classes/io/section-pair/SectionPairDocumentProvider.hpp

@@ -3,7 +3,7 @@
 * Company:         Lynar Studios
 * E-Mail:          webmaster@lynarstudios.com
 * Created:         2023-02-16
-* Changed:         2023-03-27
+* Changed:         2023-06-06
 *
 * */
 
@@ -26,6 +26,7 @@ namespace test::io
 
       [[nodiscard]] static ::std::shared_ptr<ls::std::io::SectionPairDocument> createDocument();
       [[nodiscard]] static ls::std::core::type::byte_field createSerializedDocument(const ::std::string &_newLine);
+      [[nodiscard]] static ls::std::core::type::byte_field createSerializedDocumentColineExample(const ::std::string &_newLine);
       [[nodiscard]] static ls::std::core::type::byte_field createSerializedDocumentComputerExample(const ::std::string &_newLine);
   };
 }