summaryrefslogtreecommitdiff
path: root/o3tl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-05-05 09:06:54 +0200
committerStephan Bergmann <sbergman@redhat.com>2023-05-05 11:14:48 +0200
commitc1bd421eae5449a005f2ee0f01b3b4e72002296e (patch)
treec216b08b636eed1133a4ee08d3b51fcfaa993002 /o3tl
parentf614e082055dd3cad9885d6e1968d71f1e1b5a05 (diff)
Add some o3tl::iterateCodePoints tests
Change-Id: I00f7d8bbcf7588bb2d5df1bc6f68e2d5d224bd3f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151414 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'o3tl')
-rw-r--r--o3tl/qa/test-string_view.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/o3tl/qa/test-string_view.cxx b/o3tl/qa/test-string_view.cxx
index 6569d9267705..5378ce9415ed 100644
--- a/o3tl/qa/test-string_view.cxx
+++ b/o3tl/qa/test-string_view.cxx
@@ -57,6 +57,7 @@ private:
CPPUNIT_TEST(testEndsWithRest);
CPPUNIT_TEST(testEqualsIgnoreAsciiCase);
CPPUNIT_TEST(testGetToken);
+ CPPUNIT_TEST(testIterateCodePoints);
CPPUNIT_TEST_SUITE_END();
void testStartsWith()
@@ -731,6 +732,34 @@ private:
o3tl::endsWithIgnoreAsciiCase(u"aa", u"a"));
}
}
+
+ void testIterateCodePoints()
+ {
+ {
+ std::size_t i = 1;
+ auto const c = o3tl::iterateCodePoints(u"\U00010000", &i, 1, false);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(2), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xDC00), c);
+ }
+ {
+ std::size_t i = 1;
+ auto const c = o3tl::iterateCodePoints(u"\U00010000", &i, 1, true);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(2), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), c);
+ }
+ {
+ std::size_t i = 2;
+ auto const c = o3tl::iterateCodePoints(u"a\U00010000", &i, -1, false);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(1), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x10000), c);
+ }
+ {
+ std::size_t i = 2;
+ auto const c = o3tl::iterateCodePoints(u"a\U00010000", &i, -1, true);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(0), i);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32('a'), c);
+ }
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(Test);