diff options
author | swarmer <[email protected]> | 2024-10-16 03:27:14 +0300 |
---|---|---|
committer | swarmer <[email protected]> | 2024-10-16 03:41:38 +0300 |
commit | 35c54372ef41e968a90908579c2fec61650af39e (patch) | |
tree | a5b5b61136ea8ac8e028ee6b933e5cbb29d7573e /util/string/split_ut.cpp | |
parent | d9797921c7989ee196f79f8c738da5af4894007e (diff) |
StringSplitter: recreate State after copy
commit_hash:75f3a4a20b797f07c51c63b96f0f1e1374707f33
Diffstat (limited to 'util/string/split_ut.cpp')
-rw-r--r-- | util/string/split_ut.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp index d1dac92d2d7..7c62056b907 100644 --- a/util/string/split_ut.cpp +++ b/util/string/split_ut.cpp @@ -443,6 +443,13 @@ Y_UNIT_TEST_SUITE(StringSplitter) { sum += FromString<int>(it.Token()); } UNIT_ASSERT_VALUES_EQUAL(sum, 6); + + TString ssum; + for (const auto& it : StringSplitter(" 1 2 3 " + std::string(100, ' ')).Split(' ').SkipEmpty()) { + ssum += FromString<TString>(it.Token()); + ssum += ';'; + } + UNIT_ASSERT_VALUES_EQUAL(ssum, "1;2;3;"); } Y_UNIT_TEST(TestTake) { @@ -746,6 +753,25 @@ Y_UNIT_TEST_SUITE(StringSplitter) { UNIT_ASSERT_VALUES_EQUAL(expected1, actual3); } + Y_UNIT_TEST(TesIterationAfterMove) { + const TString src = TString::Join( + "aaa", + TString(250, 'c'), + "bbb", + "aaa", + TString(250, 'c'), + "bbb"); + auto s1 = StringSplitter(std::string(src)).SplitByString("c").SkipEmpty(); + { + auto s2 = std::move(s1); + const TVector<TString> expected2 = {"aaa", "bbbaaa", "bbb"}; + const auto result2 = s2.ToList<TString>(); + UNIT_ASSERT_VALUES_EQUAL(result2, expected2); + } + const auto result1 = s1.ToList<TString>(); + Y_UNUSED(result1); // valid but unspecified value + } + Y_UNIT_TEST(TestConstCString) { const char* b = "a;b"; const char* e = b + 3; |