diff options
author | unknown <brofield@users.noreply.github.com> | 2020-06-16 20:35:12 +0300 |
---|---|---|
committer | unknown <brofield@users.noreply.github.com> | 2020-06-16 20:35:12 +0300 |
commit | 0607b9f7f7d92df418a9aec1d080193027e88726 (patch) | |
tree | 6c687afffb009b817339e26bd8f7d04a559fc678 /tests | |
parent | 592b165f35d8608b957ff05c4d8caacdbb501e95 (diff) |
Fix for issue 4 "value returned by GetValue for multiline includes ENDTAG" caused by end tags having whitespace after them
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ts-bugfix.cpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/tests/ts-bugfix.cpp b/tests/ts-bugfix.cpp index e449092..1234b8f 100644 --- a/tests/ts-bugfix.cpp +++ b/tests/ts-bugfix.cpp @@ -24,3 +24,114 @@ TEST(TestBugFix, TestEmptySection) { output.erase(std::remove(output.begin(), output.end(), '\r'), output.end()); ASSERT_STREQ(expected.c_str(), output.c_str()); } + +TEST(TestBugFix, TestMultiLineIgnoreTrailSpace0) { + std::string input = + "; multiline values\n" + "key = <<<EOS\n" + "This is a\n" + "multiline value\n" + "and it ends.\n" + "EOS\n" + "\n" + "[section]\n"; + + bool multiline = true; + CSimpleIniA ini(true, false, multiline); + + SI_Error rc = ini.LoadData(input); + ASSERT_EQ(rc, SI_OK); + + std::string output; + ini.Save(output); + + std::string expected = + "; multiline values\n" + "\n" + "\n" + "key = <<<END_OF_TEXT\n" + "This is a\n" + "multiline value\n" + "and it ends.\n" + "END_OF_TEXT\n" + "\n" + "\n" + "[section]\n"; + + output.erase(std::remove(output.begin(), output.end(), '\r'), output.end()); + ASSERT_STREQ(expected.c_str(), output.c_str()); +} + +TEST(TestBugFix, TestMultiLineIgnoreTrailSpace1) { + std::string input = + "; multiline values\n" + "key = <<<EOS\n" + "This is a\n" + "multiline value\n" + "and it ends.\n" + "EOS \n" + "\n" + "[section]\n"; + + bool multiline = true; + CSimpleIniA ini(true, false, multiline); + + SI_Error rc = ini.LoadData(input); + ASSERT_EQ(rc, SI_OK); + + std::string output; + ini.Save(output); + + std::string expected = + "; multiline values\n" + "\n" + "\n" + "key = <<<END_OF_TEXT\n" + "This is a\n" + "multiline value\n" + "and it ends.\n" + "END_OF_TEXT\n" + "\n" + "\n" + "[section]\n"; + + output.erase(std::remove(output.begin(), output.end(), '\r'), output.end()); + ASSERT_STREQ(expected.c_str(), output.c_str()); +} + +TEST(TestBugFix, TestMultiLineIgnoreTrailSpace2) { + std::string input = + "; multiline values\n" + "key = <<<EOS\n" + "This is a\n" + "multiline value\n" + "and it ends.\n" + "EOS \n" + "\n" + "[section]\n"; + + bool multiline = true; + CSimpleIniA ini(true, false, multiline); + + SI_Error rc = ini.LoadData(input); + ASSERT_EQ(rc, SI_OK); + + std::string output; + ini.Save(output); + + std::string expected = + "; multiline values\n" + "\n" + "\n" + "key = <<<END_OF_TEXT\n" + "This is a\n" + "multiline value\n" + "and it ends.\n" + "END_OF_TEXT\n" + "\n" + "\n" + "[section]\n"; + + output.erase(std::remove(output.begin(), output.end(), '\r'), output.end()); + ASSERT_STREQ(expected.c_str(), output.c_str()); +} |