+namespace {
+
+// See U_CHARSET_FAMILY in unicode/platform.h.
+const char *nativeInvChars =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789 \"%&'()*+,-./:;<=>?_";
+const char16_t *asciiInvChars =
+ u"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ u"abcdefghijklmnopqrstuvwxyz"
+ u"0123456789 \"%&'()*+,-./:;<=>?_";
+
+} // namespace
+
+void
+StringTest::TestUpperOrdinal() {
+ for (int32_t i = 0;; ++i) {
+ char ic = nativeInvChars[i];
+ uint8_t ac = asciiInvChars[i];
+ int32_t expected = ac - 'A';
+ int32_t actual = uprv_upperOrdinal(ic);
+ if (0 <= expected && expected <= 25) {
+ if (actual != expected) {
+ errln("uprv_upperOrdinal('%c')=%d != expected %d",
+ ic, (int)actual, (int)expected);
+ }
+ } else {
+ if (0 <= actual && actual <= 25) {
+ errln("uprv_upperOrdinal('%c')=%d should have been outside 0..25",
+ ic, (int)actual);
+ }
+ }
+ if (ic == 0) { break; }
+ }
+}
+
+void
+StringTest::TestLowerOrdinal() {
+ for (int32_t i = 0;; ++i) {
+ char ic = nativeInvChars[i];
+ uint8_t ac = asciiInvChars[i];
+ int32_t expected = ac - 'a';
+ int32_t actual = uprv_lowerOrdinal(ic);
+ if (0 <= expected && expected <= 25) {
+ if (actual != expected) {
+ errln("uprv_lowerOrdinal('%c')=%d != expected %d",
+ ic, (int)actual, (int)expected);
+ }
+ } else {
+ if (0 <= actual && actual <= 25) {
+ errln("uprv_lowerOrdinal('%c')=%d should have been outside 0..25",
+ ic, (int)actual);
+ }
+ }
+ if (ic == 0) { break; }
+ }
+}
+