Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Magidovich <mgsergio@mapswithme.com>2016-08-16 15:43:07 +0300
committerSergey Magidovich <mgsergio@mapswithme.com>2016-08-16 15:43:07 +0300
commit39a2cf476f96d4440147906d65cafd75583b2426 (patch)
tree6fd93b9313abe91edc813863595408c4e974d19c /base/base_tests
parent649832fdc7f26414e62c5d5a4ca4cbc9cadde731 (diff)
Add Tokenize method to get collection of strings from a string.
Diffstat (limited to 'base/base_tests')
-rw-r--r--base/base_tests/string_utils_test.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/base/base_tests/string_utils_test.cpp b/base/base_tests/string_utils_test.cpp
index 9d416c287b..304d6b2ce8 100644
--- a/base/base_tests/string_utils_test.cpp
+++ b/base/base_tests/string_utils_test.cpp
@@ -3,10 +3,13 @@
#include "base/string_utils.hpp"
#include "base/logging.hpp"
-#include "std/iomanip.hpp"
-#include "std/fstream.hpp"
#include "std/bind.hpp"
+#include "std/fstream.hpp"
+#include "std/iomanip.hpp"
+#include "std/map.hpp"
+#include "std/type_traits.hpp"
#include "std/unordered_map.hpp"
+#include "std/vector.hpp"
/// internal function in base
@@ -206,17 +209,17 @@ UNIT_TEST(to_uint)
s = "-2";
TEST(!strings::to_uint(s, i), ());
-
+
s = "0";
TEST(strings::to_uint(s, i), ());
TEST_EQUAL(0, i, ());
-
+
s = "123456789123456789123456789";
TEST(!strings::to_uint(s, i), ());
-
+
s = "labuda";
TEST(!strings::to_uint(s, i), ());
-
+
s = "AF";
TEST(strings::to_uint(s, i, 16), ());
TEST_EQUAL(175, i, ());
@@ -449,6 +452,18 @@ UNIT_TEST(SimpleTokenizer)
}
}
+UNIT_TEST(Tokenize)
+{
+ {
+ initializer_list<string> expected{"acb", "def", "ghi"};
+ TEST_EQUAL(strings::Tokenize<vector>("acb def ghi", " "), vector<string>(expected), ());
+ TEST_EQUAL(strings::Tokenize<set>("acb def ghi", " "), set<string>(expected), ());
+ }
+ {
+ static_assert(is_same<vector<string>, decltype(strings::Tokenize("", ""))>::value);
+ }
+}
+
UNIT_TEST(LastUniChar)
{
TEST_EQUAL(strings::LastUniChar(""), 0, ());