summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorConstantin Wenger <constantin.wenger@googlemail.com>2011-07-22 20:53:29 +0200
committerConstantin Wenger <constantin.wenger@googlemail.com>2011-07-22 20:53:29 +0200
commit2abe6ed75c22a0cb3154043446100baab01624fd (patch)
tree1fce6995e63b1913c628c4ead34b6feb6686bf35 /src/test.cpp
parenta12229f27148b9aec64c0fdeb1d739ad2062ac93 (diff)
parent805ccd449fdd62e05083b71c1e035e5e7347c73a (diff)
downloadminetest-2abe6ed75c22a0cb3154043446100baab01624fd.tar.gz
minetest-2abe6ed75c22a0cb3154043446100baab01624fd.tar.bz2
minetest-2abe6ed75c22a0cb3154043446100baab01624fd.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test.cpp b/src/test.cpp
index 7d71552a8..0487f1436 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -61,6 +61,38 @@ struct TestUtilities
assert(is_yes("FAlse") == false);
}
};
+
+struct TestSettings
+{
+ void Run()
+ {
+ Settings s;
+ // Test reading of settings
+ s.parseConfigLine("leet = 1337");
+ s.parseConfigLine("leetleet = 13371337");
+ s.parseConfigLine("leetleet_neg = -13371337");
+ s.parseConfigLine("floaty_thing = 1.1");
+ s.parseConfigLine("stringy_thing = asd /( ¤%&(/\" BLÖÄRP");
+ s.parseConfigLine("coord = (1, 2, 4.5)");
+ assert(s.getS32("leet") == 1337);
+ assert(s.getS16("leetleet") == 32767);
+ assert(s.getS16("leetleet_neg") == -32768);
+ // Not sure if 1.1 is an exact value as a float, but doesn't matter
+ assert(fabs(s.getFloat("floaty_thing") - 1.1) < 0.001);
+ assert(s.get("stringy_thing") == "asd /( ¤%&(/\" BLÖÄRP");
+ assert(fabs(s.getV3F("coord").X - 1.0) < 0.001);
+ assert(fabs(s.getV3F("coord").Y - 2.0) < 0.001);
+ assert(fabs(s.getV3F("coord").Z - 4.5) < 0.001);
+ // Test the setting of settings too
+ s.setFloat("floaty_thing_2", 1.2);
+ s.setV3F("coord2", v3f(1, 2, 3.3));
+ assert(s.get("floaty_thing_2").substr(0,3) == "1.2");
+ assert(fabs(s.getFloat("floaty_thing_2") - 1.2) < 0.001);
+ assert(fabs(s.getV3F("coord2").X - 1.0) < 0.001);
+ assert(fabs(s.getV3F("coord2").Y - 2.0) < 0.001);
+ assert(fabs(s.getV3F("coord2").Z - 3.3) < 0.001);
+ }
+};
struct TestCompress
{
@@ -1033,6 +1065,7 @@ void run_tests()
DSTACK(__FUNCTION_NAME);
dstream<<"run_tests() started"<<std::endl;
TEST(TestUtilities);
+ TEST(TestSettings);
TEST(TestCompress);
TEST(TestMapNode);
TEST(TestVoxelManipulator);