]> git.lizzy.rs Git - minetest.git/blobdiff - src/test.cpp
Exclude vertical mapblock borders when setting light
[minetest.git] / src / test.cpp
index e0e17bed4d05efd2842949d5750a6e63f62c4b8d..a9ec6ffbbb481f3074120c46279af370e43ffc2e 100644 (file)
@@ -59,7 +59,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define UTEST(x, fmt, ...)\
 {\
        if(!(x)){\
-               LOGLINEF(LMT_ERROR, "Test (%s) failed: " fmt, #x, ##__VA_ARGS__);\
+               dstream << "Test (" #x ") failed: " fmt << std::endl; \
                test_failed = true;\
        }\
 }
@@ -189,7 +189,7 @@ struct TestUtilities: public TestBase
                str_replace(test_str, "there", "world");
                UASSERT(test_str == "Hello world");
                test_str = "ThisAisAaAtest";
-               str_replace_char(test_str, 'A', ' ');
+               str_replace(test_str, 'A', ' ');
                UASSERT(test_str == "This is a test");
                UASSERT(string_allowed("hello", "abcdefghijklmno") == true);
                UASSERT(string_allowed("123", "abcdefghijklmno") == false);
@@ -273,8 +273,8 @@ struct TestPath: public TestBase
                                expected fs::PathStartsWith results
                                0 = returns false
                                1 = returns true
-                               2 = returns false on windows, false elsewhere
-                               3 = returns true on windows, true elsewhere
+                               2 = returns false on windows, true elsewhere
+                               3 = returns true on windows, false elsewhere
                                4 = returns true if and only if
                                    FILESYS_CASE_INSENSITIVE is true
                        */
@@ -531,9 +531,12 @@ struct TestSettings: public TestBase
                group2->setS16("num_oranges", 53);
                group2->setGroup("animals", group3);
                group2->set("animals", "cute"); //destroys group 3
+               s.setGroup("groupy_thing", group2);
 
-               // the bad chars in here should be stripped
-               s.setGroup("groupy  \"_\"  thing", group2);
+               // Test set failure conditions
+               UASSERT(s.set("Zoop = Poop\nsome_other_setting", "false") == false);
+               UASSERT(s.set("sneaky", "\"\"\"\njabberwocky = false") == false);
+               UASSERT(s.set("hehe", "asdfasdf\n\"\"\"\nsomething = false") == false);
 
                // Test multiline settings
                UASSERT(group->get("ccc") == "testy\n   testa   ");
@@ -2174,6 +2177,8 @@ void run_tests()
        IWritableNodeDefManager *ndef = createNodeDefManager();
        define_some_nodes(idef, ndef);
 
+       log_set_lev_silence(LMT_ERROR, true);
+
        infostream<<"run_tests() started"<<std::endl;
        TEST(TestUtilities);
        TEST(TestPath);
@@ -2195,6 +2200,8 @@ void run_tests()
                dout_con<<"=== END RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl;
        }
 
+       log_set_lev_silence(LMT_ERROR, false);
+
        delete idef;
        delete ndef;