From 8a70081facef94bb1dbd80a80f35ffd50d67a365 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 28 Mar 2016 20:54:07 +0300 Subject: Add test for function escapeString. --- src/utils/stringutils_unittest.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/utils/stringutils_unittest.cc b/src/utils/stringutils_unittest.cc index b921cf509..874fef359 100644 --- a/src/utils/stringutils_unittest.cc +++ b/src/utils/stringutils_unittest.cc @@ -606,6 +606,20 @@ TEST_CASE("stringuntils findAny") REQUIRE(findAny("\"one\",,two, tree", ",", 5) == 5U); } +TEST_CASE("stringuntils escapeString") +{ + REQUIRE(escapeString("") == "\"\""); + REQUIRE(escapeString("1") == "\"1\""); + REQUIRE(escapeString(" ") == "\" \""); + REQUIRE(escapeString("\"") == "\"\\\"\""); + REQUIRE(escapeString("123") == "\"123\""); + REQUIRE(escapeString("12\"3") == "\"12\\\"3\""); + REQUIRE(escapeString("12\"\"3") == "\"12\\\"\\\"3\""); + REQUIRE(escapeString("\"123\"") == "\"\\\"123\\\"\""); + REQUIRE(escapeString("\\") == "\"\\\""); + REQUIRE(escapeString("12\\3") == "\"12\\3\""); +} + TEST_CASE("stringuntils replaceItemLinks") { ItemDB::NamedItemInfos &infos = ItemDB::getNamedItemInfosTest(); -- cgit v1.2.3-70-g09d2