diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-30 10:18:10 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-30 10:18:10 +0100 |
commit | a36881648dcb2a2f620f6440845f9bd00ec3cf29 (patch) | |
tree | b057f535cf14fc72b3bcd78cdcc786c42350c2b3 /src | |
parent | 72450991eeb435a5bc1fa74da31fc862bb431e4a (diff) | |
download | rspamd-a36881648dcb2a2f620f6440845f9bd00ec3cf29.tar.gz rspamd-a36881648dcb2a2f620f6440845f9bd00ec3cf29.zip |
[Test] Update iterator tests
Diffstat (limited to 'src')
-rw-r--r-- | src/libmime/mime_string.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libmime/mime_string.cxx b/src/libmime/mime_string.cxx index 96f829574..a93ce199c 100644 --- a/src/libmime/mime_string.cxx +++ b/src/libmime/mime_string.cxx @@ -111,5 +111,41 @@ TEST_CASE("mime_string iterators") CHECK(c == in[i++]); } } + + SUBCASE("unfiltered iterator utf8") { + auto in = std::string("тест"); + UChar32 ucs[4] = {1090, 1077, 1089, 1090}; + mime_string st{in}; + CHECK(st == "тест"); + + int i = 0; + for (auto &&c : st) { + CHECK(c == ucs[i++]); + } + CHECK(i == sizeof(ucs) / sizeof(ucs[0])); + } + + SUBCASE("unfiltered raw iterator ascii") { + auto in = std::string("abcd"); + mime_string st{in}; + CHECK(st == "abcd"); + + int i = 0; + for (auto it = st.raw_begin(); it != st.raw_end(); ++it) { + CHECK(*it == in[i++]); + } + } + + SUBCASE("unfiltered raw iterator utf8") { + auto in = std::string("тест"); + mime_string st{in}; + CHECK(st == "тест"); + + int i = 0; + for (auto it = st.raw_begin(); it != st.raw_end(); ++it) { + CHECK(*it == in[i++]); + } + CHECK(i == in.size()); + } } }
\ No newline at end of file |