mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 17:33:05 +00:00
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.
This commit is contained in:
parent
2345a0d3a6
commit
97a0e8d2d9
35
test/common/ini-file.h
Normal file
35
test/common/ini-file.h
Normal file
@ -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");
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user