Merge "Add a regression test for ULocale's root/und/empty langtags handling"
diff --git a/android_icu4j/testing/src/android/icu/extratest/util/ULocaleTest.java b/android_icu4j/testing/src/android/icu/extratest/util/ULocaleTest.java
new file mode 100644
index 0000000..6b4a701
--- /dev/null
+++ b/android_icu4j/testing/src/android/icu/extratest/util/ULocaleTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.icu.extratest.util;
+
+import static org.junit.Assert.assertEquals;
+
+import android.icu.testsharding.MainTestShard;
+import android.icu.util.ULocale;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.junit.Test;
+
+@MainTestShard
+@RunWith(JUnit4.class)
+public class ULocaleTest {
+
+  /**
+   * In ICU 64.2 locale ID handling for "", "und" and "root" has been justified. In particular,
+   * ULocale.getLanguage() will return an empty string for each of these now or new
+   * ULocale("und_IN").getName() will be "_IN" for consistency.
+   */
+  @Test
+  public void testEmptyUndRootULocale() {
+    final ULocale empty = new ULocale("");
+    final ULocale und = new ULocale("und");
+    final ULocale root = new ULocale("root");
+    assertEquals("", empty.getLanguage());
+    assertEquals("", und.getLanguage());
+    assertEquals("", root.getLanguage());
+
+    final ULocale undIn = new ULocale("und_IN");
+    assertEquals("_IN", undIn.getName());
+  }
+
+}