summaryrefslogtreecommitdiff
path: root/tools/slang-test/unit-test-string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/slang-test/unit-test-string.cpp')
-rw-r--r--tools/slang-test/unit-test-string.cpp43
1 files changed, 31 insertions, 12 deletions
diff --git a/tools/slang-test/unit-test-string.cpp b/tools/slang-test/unit-test-string.cpp
index d585132c8..e27411b3e 100644
--- a/tools/slang-test/unit-test-string.cpp
+++ b/tools/slang-test/unit-test-string.cpp
@@ -84,24 +84,43 @@ static void stringUnitTest()
{
UnownedStringSlice values[] = { UnownedStringSlice("hello"), UnownedStringSlice("world"), UnownedStringSlice("!") };
+ ArrayView<UnownedStringSlice> valuesView(values, SLANG_COUNT_OF(values));
+ List<UnownedStringSlice> checkValues;
StringBuilder builder;
- builder.Clear();
- StringUtil::join(values, 0, ',', builder);
- SLANG_CHECK(builder == "");
- builder.Clear();
- StringUtil::join(values, 1, ',', builder);
- SLANG_CHECK(builder == "hello");
+ {
+ builder.Clear();
+ StringUtil::join(values, 0, ',', builder);
+ SLANG_CHECK(builder == "");
+ }
+
+ {
+ builder.Clear();
+ StringUtil::join(values, 1, ',', builder);
+ SLANG_CHECK(builder == "hello");
+ StringUtil::split(builder.getUnownedSlice(), ',', checkValues);
+ SLANG_CHECK(checkValues.getArrayView() == ArrayView<UnownedStringSlice>(values, 1));
+ }
- builder.Clear();
- StringUtil::join(values, 2, ',', builder);
- SLANG_CHECK(builder == "hello,world");
+ {
+ builder.Clear();
+ StringUtil::join(values, 2, ',', builder);
+ SLANG_CHECK(builder == "hello,world");
- builder.Clear();
- StringUtil::join(values, 3, UnownedStringSlice("ab"), builder);
- SLANG_CHECK(builder == "helloabworldab!");
+ StringUtil::split(builder.getUnownedSlice(), ',', checkValues);
+ SLANG_CHECK(checkValues.getArrayView() == ArrayView<UnownedStringSlice>(values, 2));
+ }
+
+ {
+ builder.Clear();
+ StringUtil::join(values, 3, UnownedStringSlice("ab"), builder);
+ SLANG_CHECK(builder == "helloabworldab!");
+
+ StringUtil::split(builder.getUnownedSlice(), UnownedStringSlice("ab"), checkValues);
+ SLANG_CHECK(checkValues.getArrayView() == ArrayView<UnownedStringSlice>(values, 3));
+ }
}
}