diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-04-22 09:32:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-22 09:32:25 -0400 |
| commit | da0d295d6c8b6fb03245dea0583437c198890349 (patch) | |
| tree | ed17baba750b15f6ace1427f04cf19690269161e /tools/slang-test/unit-test-string.cpp | |
| parent | 34fba7b5e726136c6eee8a318ab9a75381399c00 (diff) | |
C++ extractor improvements (#1803)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Split of NodeTree.
Split out FileUtil.
Split out MacroWriter.
* Rename slang-cpp-extractor-main.cpp -> cpp-extractor-main.cpp
* First pass at extractor unit-tests
* Initial parsing of enum.
* Ability to disable/enable parsing of scope types.
* Initial support for typedef.
* Added operator== != to ArrayVIew.
Added test for splitting to unit tests.
* Improve comment in StringUtil.
* Fix comment.
* Fix typo.
Diffstat (limited to 'tools/slang-test/unit-test-string.cpp')
| -rw-r--r-- | tools/slang-test/unit-test-string.cpp | 43 |
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)); + } } } |
