Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <iomanip>
// template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
// REQUIRES: locale.en_US.UTF-8
#include <iomanip>
#include <cassert>
#include "platform_support.h" // locale name macros
template <class CharT>
struct testbuf
: public std::basic_streambuf<CharT>
{
typedef std::basic_string<CharT> string_type;
typedef std::basic_streambuf<CharT> base;
private:
string_type str_;
public:
testbuf() {}
testbuf(const string_type& str)
: str_(str)
{
base::setg(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data()) + str_.size());
}
};
int main()
{
{
testbuf<char> sb(" -$1,234,567.89");
std::istream is(&sb);
is.imbue(std::locale(LOCALE_en_US_UTF_8));
long double x = 0;
is >> std::get_money(x, false);
assert(x == -123456789);
}
{
testbuf<char> sb(" -USD 1,234,567.89");
std::istream is(&sb);
is.imbue(std::locale(LOCALE_en_US_UTF_8));
long double x = 0;
is >> std::get_money(x, true);
assert(x == -123456789);
}
{
testbuf<wchar_t> sb(L" -$1,234,567.89");
std::wistream is(&sb);
is.imbue(std::locale(LOCALE_en_US_UTF_8));
long double x = 0;
is >> std::get_money(x, false);
assert(x == -123456789);
}
{
testbuf<wchar_t> sb(L" -USD 1,234,567.89");
std::wistream is(&sb);
is.imbue(std::locale(LOCALE_en_US_UTF_8));
long double x = 0;
is >> std::get_money(x, true);
assert(x == -123456789);
}
}

View File

@@ -0,0 +1,73 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <iomanip>
// template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
#include <iomanip>
#include <cassert>
#include "platform_support.h" // locale name macros
template <class CharT>
struct testbuf
: public std::basic_streambuf<CharT>
{
typedef std::basic_string<CharT> string_type;
typedef std::basic_streambuf<CharT> base;
private:
string_type str_;
public:
testbuf() {}
testbuf(const string_type& str)
: str_(str)
{
base::setg(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data()) + str_.size());
}
};
int main()
{
{
testbuf<char> sb(" Sat Dec 31 23:55:59 2061");
std::istream is(&sb);
is.imbue(std::locale(LOCALE_en_US_UTF_8));
std::tm t = {0};
is >> std::get_time(&t, "%a %b %d %H:%M:%S %Y");
assert(t.tm_sec == 59);
assert(t.tm_min == 55);
assert(t.tm_hour == 23);
assert(t.tm_mday == 31);
assert(t.tm_mon == 11);
assert(t.tm_year == 161);
assert(t.tm_wday == 6);
assert(is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" Sat Dec 31 23:55:59 2061");
std::wistream is(&sb);
is.imbue(std::locale(LOCALE_en_US_UTF_8));
std::tm t = {0};
is >> std::get_time(&t, L"%a %b %d %H:%M:%S %Y");
assert(t.tm_sec == 59);
assert(t.tm_min == 55);
assert(t.tm_hour == 23);
assert(t.tm_mday == 31);
assert(t.tm_mon == 11);
assert(t.tm_year == 161);
assert(t.tm_wday == 6);
assert(is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,91 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <iomanip>
// template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
// REQUIRES: locale.en_US.UTF-8
#include <iomanip>
#include <cassert>
#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 __c = base::traits_type::eof())
{
if (__c != base::traits_type::eof())
{
int n = str_.size();
str_.push_back(__c);
str_.resize(str_.capacity());
base::setp(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data() + str_.size()));
base::pbump(n+1);
}
return __c;
}
};
int main()
{
{
testbuf<char> sb;
std::ostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
showbase(os);
long double x = -123456789;
os << std::put_money(x, false);
assert(sb.str() == "-$1,234,567.89");
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
showbase(os);
long double x = -123456789;
os << std::put_money(x, true);
assert(sb.str() == "-USD 1,234,567.89");
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
showbase(os);
long double x = -123456789;
os << std::put_money(x, false);
assert(sb.str() == L"-$1,234,567.89");
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
showbase(os);
long double x = -123456789;
os << std::put_money(x, true);
assert(sb.str() == L"-USD 1,234,567.89");
}
}

View File

@@ -0,0 +1,84 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <iomanip>
// template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
#include <iomanip>
#include <cassert>
#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 __c = base::traits_type::eof())
{
if (__c != base::traits_type::eof())
{
int n = str_.size();
str_.push_back(__c);
str_.resize(str_.capacity());
base::setp(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data() + str_.size()));
base::pbump(n+1);
}
return __c;
}
};
int main()
{
{
testbuf<char> sb;
std::ostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
std::tm t = {0};
t.tm_sec = 59;
t.tm_min = 55;
t.tm_hour = 23;
t.tm_mday = 31;
t.tm_mon = 11;
t.tm_year = 161;
t.tm_wday = 6;
t.tm_isdst = 0;
os << std::put_time(&t, "%a %b %d %H:%M:%S %Y");
assert(sb.str() == "Sat Dec 31 23:55:59 2061");
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.imbue(std::locale(LOCALE_en_US_UTF_8));
std::tm t = {0};
t.tm_sec = 59;
t.tm_min = 55;
t.tm_hour = 23;
t.tm_mday = 31;
t.tm_mon = 11;
t.tm_year = 161;
t.tm_wday = 6;
os << std::put_time(&t, L"%a %b %d %H:%M:%S %Y");
assert(sb.str() == L"Sat Dec 31 23:55:59 2061");
}
}