+
+void LocaleTest::TestIsRightToLeft() {
+ assertFalse("root LTR", Locale::getRoot().isRightToLeft());
+ assertFalse("zh LTR", Locale::getChinese().isRightToLeft());
+ assertTrue("ar RTL", Locale("ar").isRightToLeft());
+ assertTrue("und-EG RTL", Locale("und-EG").isRightToLeft(), FALSE, TRUE);
+ assertFalse("fa-Cyrl LTR", Locale("fa-Cyrl").isRightToLeft());
+ assertTrue("en-Hebr RTL", Locale("en-Hebr").isRightToLeft());
+ assertTrue("ckb RTL", Locale("ckb").isRightToLeft(), FALSE, TRUE); // Sorani Kurdish
+ assertFalse("fil LTR", Locale("fil").isRightToLeft());
+ assertFalse("he-Zyxw LTR", Locale("he-Zyxw").isRightToLeft());
+}
+
+void LocaleTest::TestBug11421() {
+ Locale::getDefault().getBaseName();
+ int32_t numLocales;
+ const Locale *localeList = Locale::getAvailableLocales(numLocales);
+ for (int localeIndex = 0; localeIndex < numLocales; localeIndex++) {
+ const Locale &loc = localeList[localeIndex];
+ if (strncmp(loc.getName(), loc.getBaseName(), strlen(loc.getBaseName()))) {
+ errln("%s:%d loc.getName=\"%s\"; loc.getBaseName=\"%s\"",
+ __FILE__, __LINE__, loc.getName(), loc.getBaseName());
+ break;
+ }
+ }
+}
+
+// TestBug13277. The failure manifests as valgrind errors.
+// See the trac ticket for details.
+//
+
+void LocaleTest::TestBug13277() {
+ UErrorCode status = U_ZERO_ERROR;
+ CharString name("en-us-x-foo", -1, status);
+ while (name.length() < 152) {
+ name.append("-x-foo", -1, status);
+ }
+
+ while (name.length() < 160) {
+ name.append('z', status);
+ Locale loc(name.data(), nullptr, nullptr, nullptr);
+ }
+}
+
+// TestBug13554 Check for read past end of array in getPosixID().
+// The bug shows as an Address Sanitizer failure.
+
+void LocaleTest::TestBug13554() {
+ UErrorCode status = U_ZERO_ERROR;
+ const int BUFFER_SIZE = 100;
+ char posixID[BUFFER_SIZE];
+
+ for (uint32_t hostid = 0; hostid < 0x500; ++hostid) {
+ status = U_ZERO_ERROR;
+ uprv_convertToPosix(hostid, posixID, BUFFER_SIZE, &status);
+ }
+}
+
+