Files
clang-p2996/libcxx/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp
Ryan Prichard bce3b50593 [libc++][Android] Mark tests XFAIL/UNSUPPORTED (#69271)
Mark tests as necessary to accommodate Android L (5.0 / API 21) and up.

Add three Android lit features:
 - android
 - android-device-api=(21,22,23,...)
 - LIBCXX-ANDROID-FIXME (for failures that need follow-up work)

Enable an AIX workaround in filesystem_test_helper.h for the broken
chmod on older Android devices.

Mark failing test with XFAIL or UNSUPPORTED:
 - Mark modules tests as UNSUPPORTED, matching other configurations.
 - Mark a gdb test as UNSUPPORTED.
 - XFAIL tests for old devices that lack an API (fmemopen).
- XFAIL various FS tests (because SELinux blocks FIFO and hard linking,
because fchmodat is broken on old devices).
- XFAIL various locale tests (because Bionic has limited locale
support). (Also XFAIL an re.traits test.)
- XFAIL some print.fun tests because the error exception has no system
error string.
- Mark std::{cin,wcin} tests UNSUPPORTED because they hang with
adb_run.py on old devices.
 - Mark a few tests UNSUPPORTED because they allocate too much memory.
 - notify_one.pass.cpp is flaky on Android.
- XFAIL libc++abi demangler test because of Android's special long
double on x86[-64].

N.B. The `__ANDROID_API__` macro specifies a minimum required API level
at build-time, whereas the android-device-api lit feature is the
detected API level of the device at run-time. The android-device-api
value will be >= `__ANDROID_API__`.

This commit was split out from https://reviews.llvm.org/D139147.

Fixes: https://github.com/llvm/llvm-project/issues/69270
2023-10-19 17:27:01 -07:00

116 lines
3.0 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <iomanip>
// template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
// Bionic has minimal locale support, investigate this later.
// XFAIL: LIBCXX-ANDROID-FIXME
// REQUIRES: locale.en_US.UTF-8
#include <iomanip>
#include <ostream>
#include <cassert>
#include "test_macros.h"
#include "platform_support.h" // locale name macros
template <class CharT>
class testbuf
: public std::basic_streambuf<CharT>
{
typedef std::basic_streambuf<CharT> base;
std::basic_string<CharT> str_;
public:
testbuf()
{
}
std::basic_string<CharT> str() const
{return std::basic_string<CharT>(base::pbase(), base::pptr());}
protected:
virtual typename base::int_type
overflow(typename base::int_type ch = base::traits_type::eof())
{
if (ch != base::traits_type::eof())
{
int n = str_.size();
str_.push_back(static_cast<CharT>(ch));
str_.resize(str_.capacity());
base::setp(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data() + str_.size()));
base::pbump(n+1);
}
return ch;
}
};
int main(int, char**)
{
{
testbuf<char> sb;
std::ostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
std::showbase(os);
long double x = -123456789;
os << std::put_money(x, false);
#if defined(_WIN32)
assert(sb.str() == "($1,234,567.89)");
#else
assert(sb.str() == "-$1,234,567.89");
#endif
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
std::showbase(os);
long double x = -123456789;
os << std::put_money(x, true);
#if defined(_WIN32)
assert(sb.str() == "(USD1,234,567.89)");
#else
assert(sb.str() == "-USD 1,234,567.89");
#endif
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
std::showbase(os);
long double x = -123456789;
os << std::put_money(x, false);
#if defined(_WIN32)
assert(sb.str() == L"($1,234,567.89)");
#else
assert(sb.str() == L"-$1,234,567.89");
#endif
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
std::showbase(os);
long double x = -123456789;
os << std::put_money(x, true);
#if defined(_WIN32)
assert(sb.str() == L"(USD1,234,567.89)");
#else
assert(sb.str() == L"-USD 1,234,567.89");
#endif
}
#endif
return 0;
}