summaryrefslogtreecommitdiff
path: root/src/unittest/test_utilities.cpp
diff options
context:
space:
mode:
authorBen Deutsch <ben@bendeutsch.de>2018-08-05 13:13:38 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-08-05 13:13:38 +0200
commit153fb211ac2342907eb766a79c1f41824f981ab5 (patch)
tree58a927bbf9a7d3d3811df6a703de02362b6474fb /src/unittest/test_utilities.cpp
parent18368824958139f1428d534082852d778982b4c9 (diff)
downloadminetest-153fb211ac2342907eb766a79c1f41824f981ab5.tar.gz
minetest-153fb211ac2342907eb766a79c1f41824f981ab5.tar.bz2
minetest-153fb211ac2342907eb766a79c1f41824f981ab5.zip
Replace auth.txt with SQLite auth database (#7279)
* Replace auth.txt with SQLite auth database
Diffstat (limited to 'src/unittest/test_utilities.cpp')
-rw-r--r--src/unittest/test_utilities.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp
index 315cbf0fc..6f4a01432 100644
--- a/src/unittest/test_utilities.cpp
+++ b/src/unittest/test_utilities.cpp
@@ -51,6 +51,7 @@ public:
void testIsNumber();
void testIsPowerOfTwo();
void testMyround();
+ void testStringJoin();
};
static TestUtilities g_test_instance;
@@ -78,6 +79,7 @@ void TestUtilities::runTests(IGameDef *gamedef)
TEST(testIsNumber);
TEST(testIsPowerOfTwo);
TEST(testMyround);
+ TEST(testStringJoin);
}
////////////////////////////////////////////////////////////////////////////////
@@ -328,3 +330,24 @@ void TestUtilities::testMyround()
UASSERT(myround(-6.5f) == -7);
}
+void TestUtilities::testStringJoin()
+{
+ std::vector<std::string> input;
+ UASSERT(str_join(input, ",") == "");
+
+ input.emplace_back("one");
+ UASSERT(str_join(input, ",") == "one");
+
+ input.emplace_back("two");
+ UASSERT(str_join(input, ",") == "one,two");
+
+ input.emplace_back("three");
+ UASSERT(str_join(input, ",") == "one,two,three");
+
+ input[1] = "";
+ UASSERT(str_join(input, ",") == "one,,three");
+
+ input[1] = "two";
+ UASSERT(str_join(input, " and ") == "one and two and three");
+}
+