summaryrefslogtreecommitdiff
path: root/i18nutil/qa/cppunit/test_kashida.cxx
diff options
context:
space:
mode:
authorJonathan Clark <jonathan@libreoffice.org>2024-09-26 02:59:26 -0600
committerJonathan Clark <jonathan@libreoffice.org>2024-09-27 03:50:01 +0200
commitc3c29d31d77ff93aa50634cfd51c62d12dc0f6ec (patch)
tree0c938a2c80e3de61c8f6aa6133a187d96ba8fb2f /i18nutil/qa/cppunit/test_kashida.cxx
parentd8f430e4bef414616fd80bbf4ea16d767991b5b9 (diff)
tdf#140767 Implemented Syriac justification
This change extends kashida justification to Syriac, using custom insertion rules. Change-Id: I7508d2c32e95abb12a098e989c7153828ba81c87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173990 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Diffstat (limited to 'i18nutil/qa/cppunit/test_kashida.cxx')
-rw-r--r--i18nutil/qa/cppunit/test_kashida.cxx45
1 files changed, 43 insertions, 2 deletions
diff --git a/i18nutil/qa/cppunit/test_kashida.cxx b/i18nutil/qa/cppunit/test_kashida.cxx
index 46b40c2a5b7a..e0526c4c8f93 100644
--- a/i18nutil/qa/cppunit/test_kashida.cxx
+++ b/i18nutil/qa/cppunit/test_kashida.cxx
@@ -26,6 +26,7 @@ public:
void testFinalYeh();
void testNoZwnjExpansion();
void testExcludeInvalid();
+ void testSyriac();
CPPUNIT_TEST_SUITE(KashidaTest);
CPPUNIT_TEST(testCharacteristic);
@@ -33,6 +34,7 @@ public:
CPPUNIT_TEST(testFinalYeh);
CPPUNIT_TEST(testNoZwnjExpansion);
CPPUNIT_TEST(testExcludeInvalid);
+ CPPUNIT_TEST(testSyriac);
CPPUNIT_TEST_SUITE_END();
};
@@ -69,7 +71,9 @@ void KashidaTest::testManualKashida()
// tdf#65344: Do not insert kashida before a final Yeh
void KashidaTest::testFinalYeh()
{
- CPPUNIT_ASSERT(!GetWordKashidaPosition(u"نیمِي"_ustr).has_value());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), GetWordKashidaPosition(u"يييي"_ustr).value().nIndex);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetWordKashidaPosition(u"ييي"_ustr).value().nIndex);
+ CPPUNIT_ASSERT(!GetWordKashidaPosition(u"يي"_ustr).has_value());
// Should always insert kashida after Seen, even before a final Yeh
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), GetWordKashidaPosition(u"كرسي"_ustr).value().nIndex);
@@ -82,7 +86,7 @@ void KashidaTest::testNoZwnjExpansion()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetWordKashidaPosition(u"نویس\u200Cه"_ustr).value().nIndex);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), GetWordKashidaPosition(u"متن"_ustr).value().nIndex);
- CPPUNIT_ASSERT(!GetWordKashidaPosition(u"مت\u200Cن"_ustr).has_value());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetWordKashidaPosition(u"مت\u200Cن"_ustr).value().nIndex);
}
// tdf#163105: Do not insert kashida if the position is invalid
@@ -111,6 +115,43 @@ void KashidaTest::testExcludeInvalid()
CPPUNIT_ASSERT(!GetWordKashidaPosition(u"نویسه"_ustr, aValid).has_value());
}
+// tdf#140767: Kashida justification for Syriac
+void KashidaTest::testSyriac()
+{
+ // - Prefer user-inserted kashida
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), GetWordKashidaPosition(u"ܥܥـܥܥܥܥ"_ustr).value().nIndex);
+
+ std::vector<bool> aValid;
+ aValid.resize(7, true);
+
+ // - Start from end and work toward midpoint, then reverse direction
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5),
+ GetWordKashidaPosition(u"ܥܥܥܥܥܥܥ"_ustr, aValid).value().nIndex);
+ aValid[5] = false;
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4),
+ GetWordKashidaPosition(u"ܥܥܥܥܥܥܥ"_ustr, aValid).value().nIndex);
+ aValid[4] = false;
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0),
+ GetWordKashidaPosition(u"ܥܥܥܥܥܥܥ"_ustr, aValid).value().nIndex);
+ aValid[0] = false;
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
+ GetWordKashidaPosition(u"ܥܥܥܥܥܥܥ"_ustr, aValid).value().nIndex);
+ aValid[1] = false;
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2),
+ GetWordKashidaPosition(u"ܥܥܥܥܥܥܥ"_ustr, aValid).value().nIndex);
+ aValid[2] = false;
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3),
+ GetWordKashidaPosition(u"ܥܥܥܥܥܥܥ"_ustr, aValid).value().nIndex);
+ aValid[3] = false;
+
+ CPPUNIT_ASSERT(!GetWordKashidaPosition(u"ܥܥܥܥܥܥܥ"_ustr, aValid).has_value());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(KashidaTest);
}