]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Update iterator tests
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 30 Sep 2021 09:18:10 +0000 (10:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 30 Sep 2021 09:18:10 +0000 (10:18 +0100)
src/libmime/mime_string.cxx

index 96f82957493d2097bc4f71dcc3ec7bc0636f831f..a93ce199cff7c7cccff5760d6bee32a910fe0f93 100644 (file)
@@ -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