[Define to 1 if the linker supports weak symbols.])
fi
+
+# Figure out if we support wchar well
+AC_CACHE_CHECK(
+ [for wchar support],
+ [folly_cv_prog_cc_wchar_support],
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE[
+ #include <cstddef>
+ #include <cwchar>
+
+ int main(int argc, char** argv) {
+ return wcstol(L"01", nullptr, 10) == 1 ? 0 : 1;
+ }
+ ]],
+ [folly_cv_prog_cc_wchar_support=yes],
+ [folly_cv_prog_cc_wchar_support=no])])
+
+if test "$folly_cv_prog_cc_wchar_support" = "yes"; then
+ AC_DEFINE([HAVE_WCHAR_SUPPORT], [1], [Define to 1 if the libc supports wchar well])
+fi
+
# Figure out whether the architecture supports unaligned accesses
AC_CACHE_CHECK(
[for unaligned access support],
EXPECT_TRUE(1) << "Starting with seed: " << seed;
std::string r;
folly::fbstring c;
-#ifndef __ANDROID__
- // Disabled on Android: wchar support is not recommended and does not
- // always behave as expected
+#if FOLLY_HAVE_WCHAR_SUPPORT
std::wstring wr;
folly::basic_fbstring<wchar_t> wc;
#endif
randomString(&r);
c = r;
EXPECT_EQ(c, r);
-#ifndef __ANDROID__
+#if FOLLY_HAVE_WCHAR_SUPPORT
wr = std::wstring(r.begin(), r.end());
wc = folly::basic_fbstring<wchar_t>(wr.c_str());
#endif
<< "Lengths: " << r.size() << " vs. " << c.size()
<< "\nReference: '" << r << "'"
<< "\nActual: '" << c.data()[0] << "'";
-#ifndef __ANDROID__
+#if FOLLY_HAVE_WCHAR_SUPPORT
rng = RandomT(localSeed);
f_wfbstring(wc);
int wret = wcslen(wc.c_str());
EXPECT_NE(hashfunc(a), hashfunc(b));
}
+#if FOLLY_HAVE_WCHAR_SUPPORT
TEST(FBString, testHashChar16) {
using u16fbstring = basic_fbstring<char16_t>;
u16fbstring a;
std::hash<u16fbstring> hashfunc;
EXPECT_NE(hashfunc(a), hashfunc(b));
}
+#endif
TEST(FBString, testFrontBack) {
fbstring str("hello");