about summary refs log tree commit diff
path: root/absl/strings/ascii_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/strings/ascii_test.cc')
-rw-r--r--absl/strings/ascii_test.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/absl/strings/ascii_test.cc b/absl/strings/ascii_test.cc
index 97f36013bd61..9903b0496b77 100644
--- a/absl/strings/ascii_test.cc
+++ b/absl/strings/ascii_test.cc
@@ -130,9 +130,11 @@ TEST(AsciiIsFoo, All) {
 // Checks that absl::ascii_isfoo returns the same value as isfoo in the C
 // locale.
 TEST(AsciiIsFoo, SameAsIsFoo) {
+#ifndef __ANDROID__
   // temporarily change locale to C. It should already be C, but just for safety
-  std::string old_locale = setlocale(LC_CTYPE, nullptr);
-  ASSERT_TRUE(setlocale(LC_CTYPE, "C"));
+  const char* old_locale = setlocale(LC_CTYPE, "C");
+  ASSERT_TRUE(old_locale != nullptr);
+#endif
 
   for (int i = 0; i < 256; i++) {
     EXPECT_EQ(isalpha(i) != 0, absl::ascii_isalpha(i)) << i;
@@ -150,14 +152,18 @@ TEST(AsciiIsFoo, SameAsIsFoo) {
     EXPECT_EQ(isascii(i) != 0, absl::ascii_isascii(i)) << i;
   }
 
+#ifndef __ANDROID__
   // restore the old locale.
-  ASSERT_TRUE(setlocale(LC_CTYPE, old_locale.c_str()));
+  ASSERT_TRUE(setlocale(LC_CTYPE, old_locale));
+#endif
 }
 
 TEST(AsciiToFoo, All) {
+#ifndef __ANDROID__
   // temporarily change locale to C. It should already be C, but just for safety
-  std::string old_locale = setlocale(LC_CTYPE, nullptr);
-  ASSERT_TRUE(setlocale(LC_CTYPE, "C"));
+  const char* old_locale = setlocale(LC_CTYPE, "C");
+  ASSERT_TRUE(old_locale != nullptr);
+#endif
 
   for (int i = 0; i < 256; i++) {
     if (absl::ascii_islower(i))
@@ -180,9 +186,10 @@ TEST(AsciiToFoo, All) {
     EXPECT_EQ(absl::ascii_tolower(i), absl::ascii_tolower(sc)) << i;
     EXPECT_EQ(absl::ascii_toupper(i), absl::ascii_toupper(sc)) << i;
   }
-
+#ifndef __ANDROID__
   // restore the old locale.
-  ASSERT_TRUE(setlocale(LC_CTYPE, old_locale.c_str()));
+  ASSERT_TRUE(setlocale(LC_CTYPE, old_locale));
+#endif
 }
 
 TEST(AsciiStrTo, Lower) {