Add extra tests compiled aganist libicu into CtsIcu4cTestCases

Bug: 160350521
Test: atest CtsIcu4cTestCases
Change-Id: I4a7a7b0bacec43942e56fff5c64e8f77f9485e31
diff --git a/libicu/test/Android.bp b/libicu/test/Android.bp
new file mode 100644
index 0000000..a859016
--- /dev/null
+++ b/libicu/test/Android.bp
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 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 {
+    default_visibility: [
+        "//external/icu:__subpackages__",
+        "//cts/tests/tests/icu:__subpackages__",
+    ],
+}
+
+cc_test_library {
+    name: "libicutest_static",
+    defaults: ["icu4c_defaults"],
+    sdk_version: "current",
+    stl: "c++_static",
+    srcs: ["src/*.cpp"],
+    shared_libs: [
+        "libicu",
+        "liblog",
+    ],
+    gtest: true,
+    tidy: true,
+    installable: false,
+}
diff --git a/libicu/test/src/uchar_test.cpp b/libicu/test/src/uchar_test.cpp
new file mode 100644
index 0000000..09c54fb
--- /dev/null
+++ b/libicu/test/src/uchar_test.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include <unicode/uchar.h>
+
+TEST(Icu4cUCharTest, test_u_hasBinaryProperty) {
+  ASSERT_TRUE(u_hasBinaryProperty(U' '  /* ascii space */, UCHAR_WHITE_SPACE));
+  ASSERT_TRUE(u_hasBinaryProperty(8200 /* Punctuation space U+2008 */, UCHAR_WHITE_SPACE));
+  ASSERT_TRUE(u_hasBinaryProperty(U'❤' /* Emoji heart U+2764 */, UCHAR_EMOJI));
+  ASSERT_FALSE(u_hasBinaryProperty(U'❤' /* Emoji heart U+2764 */, UCHAR_WHITE_SPACE));
+}
+
+TEST(Icu4cUCharTest, test_u_toupper) {
+  ASSERT_EQ(U'A', u_toupper(U'a'));
+  ASSERT_EQ(U'A', u_toupper(U'A'));
+  ASSERT_EQ(U'1', u_toupper(U'1'));
+  ASSERT_EQ(U'Ë', u_toupper(U'ë'));
+}
diff --git a/libicu/test/src/uloc_test.cpp b/libicu/test/src/uloc_test.cpp
new file mode 100644
index 0000000..15632cd
--- /dev/null
+++ b/libicu/test/src/uloc_test.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include <vector>
+#include <unicode/uloc.h>
+
+bool is_enUS(const char* s) {
+  return s != nullptr && std::strcmp("en_US", s) == 0;
+}
+
+TEST(Icu4cLocaleTest, test_uloc_getAvailable) {
+  int32_t count = uloc_countAvailable();
+  ASSERT_GT(uloc_countAvailable(), 0);
+
+  std::vector<const char*> locales(count);
+  for(int i = 0; i < count; i++) {
+    locales.push_back(uloc_getAvailable(i));
+  }
+
+  // On Android, uloc_getAvailable must contain en_US.
+  ASSERT_NE(locales.end(), std::find_if(locales.begin(), locales.end(), is_enUS));
+}
+
+TEST(Icu4cLocaleTest, test_uloc_getCountry) {
+  char country[4];
+  UErrorCode error;
+  uloc_getCountry("en_US", country, sizeof(country), &error);
+  ASSERT_EQ(U_ZERO_ERROR, error);
+  EXPECT_STREQ("US", country);
+}
\ No newline at end of file