commit a368816: [Test] Update iterator tests

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Sep 30 09:21:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-09-30 10:18:10 +0100
URL: https://github.com/rspamd/rspamd/commit/a36881648dcb2a2f620f6440845f9bd00ec3cf29

[Test] Update iterator tests

---
 src/libmime/mime_string.cxx | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

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


More information about the Commits mailing list