Extend minetest.is_yes()
authorred-001 <red-001@outlook.ie>
Sat, 3 Dec 2016 11:38:07 +0000 (11:38 +0000)
committerNer'zhul <nerzhul@users.noreply.github.com>
Sat, 7 Jan 2017 08:54:51 +0000 (09:54 +0100)
src/unittest/test_utilities.cpp
src/util/string.h

index d73975b9f84f11076932388f9a7372bc3e6ea4e6..58412dd85cb8dde84c7f0c13fbcd2eda0a83cf9f 100644 (file)
@@ -147,6 +147,8 @@ void TestUtilities::testIsYes()
        UASSERT(is_yes("0") == false);
        UASSERT(is_yes("1") == true);
        UASSERT(is_yes("2") == true);
+       UASSERT(is_yes("on") == true);
+       UASSERT(is_yes("off") == false);
 }
 
 
index 572c371502c5965167c764d3110cd72488034b2d..ba3c09e513c2c18629e3b438cfc384d6dc6f5ae2 100644 (file)
@@ -272,7 +272,7 @@ inline bool is_yes(const std::string &str)
 {
        std::string s2 = lowercase(trim(str));
 
-       return s2 == "y" || s2 == "yes" || s2 == "true" || atoi(s2.c_str()) != 0;
+       return s2 == "y" || s2 == "yes" || s2 == "true" || s2 == "on" || atoi(s2.c_str()) != 0;
 }