+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2014, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* file name: cbiditst.c
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
static void doTailTest(void);
static void testBracketOverflow(void);
+static void TestExplicitLevel0();
/* new BIDI API */
static void testReorderingMode(void);
addTest(root, testGetBaseDirection, "complex/bidi/testGetBaseDirection");
addTest(root, testContext, "complex/bidi/testContext");
addTest(root, testBracketOverflow, "complex/bidi/TestBracketOverflow");
+ addTest(root, &TestExplicitLevel0, "complex/bidi/TestExplicitLevel0");
addTest(root, doArabicShapingTest, "complex/arabic-shaping/ArabicShapingTest");
addTest(root, doLamAlefSpecialVLTRArabicShapingTest, "complex/arabic-shaping/lamalef");
ubidi_close(bidi);
}
+static void TestExplicitLevel0() {
+ // The following used to fail with an error, see ICU ticket #12922.
+ static const UChar text[2] = { 0x202d, 0x05d0 };
+ static UBiDiLevel embeddings[2] = { 0, 0 };
+ UErrorCode errorCode = U_ZERO_ERROR;
+ UBiDi *bidi = ubidi_open();
+ ubidi_setPara(bidi, text, 2, UBIDI_DEFAULT_LTR , embeddings, &errorCode);
+ if (U_FAILURE(errorCode)) {
+ log_err("ubidi_setPara() - %s", u_errorName(errorCode));
+ } else {
+ UBiDiLevel level0 = ubidi_getLevelAt(bidi, 0);
+ UBiDiLevel level1 = ubidi_getLevelAt(bidi, 1);
+ if (level0 != 1 || level1 != 1) {
+ log_err("resolved levels != 1: { %d, %d }\n", level0, level1);
+ }
+ if (embeddings[0] != 1 || embeddings[1] != 1) {
+ log_err("modified embeddings[] levels != 1: { %d, %d }\n", embeddings[0], embeddings[1]);
+ }
+ }
+ ubidi_close(bidi);
+}