diff options
Diffstat (limited to 'tests/ts-bugfix.cpp')
-rw-r--r-- | tests/ts-bugfix.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ts-bugfix.cpp b/tests/ts-bugfix.cpp new file mode 100644 index 0000000..e449092 --- /dev/null +++ b/tests/ts-bugfix.cpp @@ -0,0 +1,26 @@ +#include "pch.h" +#include "../SimpleIni.h" + +TEST(TestBugFix, TestEmptySection) { + CSimpleIniA ini; + ini.SetValue("foo", "skey", "sval"); + ini.SetValue("", "rkey", "rval"); + ini.SetValue("bar", "skey", "sval"); + + std::string output; + ini.Save(output); + + std::string expected = + "rkey = rval\n" + "\n" + "\n" + "[foo]\n" + "skey = sval\n" + "\n" + "\n" + "[bar]\n" + "skey = sval\n"; + + output.erase(std::remove(output.begin(), output.end(), '\r'), output.end()); + ASSERT_STREQ(expected.c_str(), output.c_str()); +} |