o3tl/qa/test-string_view.cxx |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

New commits:
commit c1bd421eae5449a005f2ee0f01b3b4e72002296e
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Fri May 5 09:06:54 2023 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri May 5 11:14:48 2023 +0200

    Add some o3tl::iterateCodePoints tests
    
    Change-Id: I00f7d8bbcf7588bb2d5df1bc6f68e2d5d224bd3f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151414
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

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);

Reply via email to