[Scummvm-git-logs] scummvm master -> 97a0e8d2d925dc51e90c804e8301929d53860c23
mduggan
noreply at scummvm.org
Fri Mar 25 08:37:33 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
97a0e8d2d9 TEST: Add tests for Common::INIFile
Commit: 97a0e8d2d925dc51e90c804e8301929d53860c23
https://github.com/scummvm/scummvm/commit/97a0e8d2d925dc51e90c804e8301929d53860c23
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2022-03-25T17:35:51+09:00
Commit Message:
TEST: Add tests for Common::INIFile
This is partly an attempt to fix the build on debian and windows as apparently
the INIFile class is not being linked in to the tests.
Changed paths:
A test/common/ini-file.h
diff --git a/test/common/ini-file.h b/test/common/ini-file.h
new file mode 100644
index 00000000000..d3a6a418930
--- /dev/null
+++ b/test/common/ini-file.h
@@ -0,0 +1,35 @@
+#include <cxxtest/TestSuite.h>
+
+#include "common/ini-file.h"
+#include "common/memstream.h"
+
+class IniFileTestSuite : public CxxTest::TestSuite {
+ public:
+ void test_blank_ini_file() {
+ Common::INIFile inifile;
+
+ TS_ASSERT(!inifile.hasSection("abc"));
+
+ Common::INIFile::SectionList sections = inifile.getSections();
+ TS_ASSERT_EQUALS(sections.size(), 0);
+ }
+
+ void test_simple_ini_file() {
+ const unsigned char data[] = "[s]\nabc=1\ndef=xyz";
+ Common::MemoryReadStream ms(data, sizeof(data));
+
+ Common::INIFile inifile;
+ bool result = inifile.loadFromStream(ms);
+ TS_ASSERT(result);
+
+ TS_ASSERT(inifile.hasSection("s"));
+ TS_ASSERT(inifile.hasKey("abc", "s"));
+
+ Common::String val;
+ TS_ASSERT(inifile.getKey("abc", "s", val));
+ TS_ASSERT_EQUALS(val, "1");
+ inifile.setKey("abc", "s", "newval");
+ TS_ASSERT(inifile.getKey("abc", "s", val));
+ TS_ASSERT_EQUALS(val, "newval");
+ }
+};
More information about the Scummvm-git-logs
mailing list