1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00
openrw/tests/test_config.cpp
Anonymous Maarten 05db65dbbc config: allow reading INI from string, file, default and current config
This (slightly more complicated implementation) allows us,
once a configuration menu has been implemented,
to store the current/new configuration to a INI file.

The definitions of the parameters in rwgame/GameConfig.cpp
is limited to one location.
2017-02-20 01:01:30 +00:00

29 lines
781 B
C++

#include <GameConfig.hpp>
#include <boost/test/unit_test.hpp>
#include <fstream>
BOOST_AUTO_TEST_SUITE(ConfigTests)
BOOST_AUTO_TEST_CASE(test_loading) {
// Write out a temporary file
std::ofstream test_config("/tmp/openrw_test.ini");
test_config << "[game]\n"
<< "\tpath=\t/dev/test\n"
<< " language = american ;Comment\n"
<< ";lineComment\n"
<< "nonexistingkey=somevalue"
<< std::endl;
GameConfig config("openrw_test.ini", "/tmp");
BOOST_CHECK(config.isValid());
BOOST_CHECK_EQUAL(config.getGameDataPath(), "/dev/test");
BOOST_CHECK_EQUAL(config.getGameLanguage(), "american");
BOOST_CHECK_EQUAL(config.getInputInvertY(), false);
}
BOOST_AUTO_TEST_SUITE_END()