From 7413dc783ea169cb22b26487eec6397266a2235f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 29 Aug 2020 22:06:33 -0400 Subject: [PATCH] add tokenizer tests for splitting path environment variables --- unittest/utils/test_tokenizer.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/unittest/utils/test_tokenizer.cpp b/unittest/utils/test_tokenizer.cpp index 12e59cf83b..001b7095de 100644 --- a/unittest/utils/test_tokenizer.cpp +++ b/unittest/utils/test_tokenizer.cpp @@ -62,6 +62,28 @@ TEST(Tokenizer, iterate_words) ASSERT_EQ(t.count(), 2); } +TEST(Tokenizer, unix_paths) +{ + Tokenizer t(":one:two:three:", ":"); + ASSERT_EQ(t.count(), 3); + ASSERT_THAT(t.next(), Eq("one")); + ASSERT_THAT(t.next(), Eq("two")); + ASSERT_EQ(t.has_next(), true); + ASSERT_THAT(t.next(), Eq("three")); + ASSERT_EQ(t.has_next(), false); +} + +TEST(Tokenizer, windows_paths) +{ + Tokenizer t("c:\\one;\\two\\three;d:four;", ";"); + ASSERT_EQ(t.count(), 3); + ASSERT_THAT(t.next(), Eq("c:\\one")); + ASSERT_EQ(t.has_next(), true); + ASSERT_THAT(t.next(), Eq("\\two\\three")); + ASSERT_THAT(t.next(), Eq("d:four")); + ASSERT_EQ(t.has_next(), false); +} + TEST(Tokenizer, default_separators) { Tokenizer t(" \r\n test \t word \f");