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,12 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(bool val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
bool b = false;
os << b;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
bool b = false;
os << b;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
bool b = true;
os << b;
assert(sb.str() == "1");
}
{
testbuf<char> sb;
std::ostream os(&sb);
boolalpha(os);
bool b = true;
os << b;
assert(sb.str() == "true");
}
{
testbuf<char> sb;
std::ostream os(&sb);
boolalpha(os);
bool b = false;
os << b;
assert(sb.str() == "false");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(double val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
double n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
double n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
double n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
double n = -10.5;
os << n;
assert(sb.str() == "-10.5");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(float val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
float n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
float n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
float n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
float n = -10.5;
os << n;
assert(sb.str() == "-10.5");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(int val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
int n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
int n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
int n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
int n = -10;
os << n;
assert(sb.str() == "fffffff6");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(long val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
long n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
long n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
long n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
long n = 0xfffffff6;
os << n;
assert(sb.str() == "fffffff6");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(long double val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
long double n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
long double n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
long double n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
long double n = -10.5;
os << n;
assert(sb.str() == "-10.5");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(long long val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
long long n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
long long n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
long long n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
long long n = -10;
os << n;
assert(sb.str() == "fffffffffffffff6");
}
}

View File

@@ -0,0 +1,82 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(const void* val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
const void* n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
const void* n = 0;
os << n;
assert(os.good());
// %p is implementation defined.
// On some platforms (Windows), it's a hex number without
// any leading 0x like prefix.
// In that format, we assume a null pointer will yield 2 '0' hex digits
// for each 8 bits of address space.
assert(sb.str() == "0x0" || sb.str() == "(nil)" ||
sb.str() == std::string(sizeof(void*)*2,'0'));
}
{
testbuf<char> sb;
std::ostream os(&sb);
const void* n = &sb;
os << n;
assert(os.good());
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(short val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
short n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
short n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
short n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
short n = -10;
os << n;
assert(sb.str() == "fff6");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(unsigned int val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
unsigned int n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned int n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned int n = 10;
os << n;
assert(sb.str() == "10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
unsigned int n = 0xFFF6;
os << n;
assert(sb.str() == "fff6");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(unsigned long val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
unsigned long n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned long n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned long n = 10;
os << n;
assert(sb.str() == "10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
unsigned long n = 0xfffffff6;
os << n;
assert(sb.str() == "fffffff6");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(unsigned long long val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
unsigned long long n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned long long n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned long long n = 10;
os << n;
assert(sb.str() == "10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
unsigned long long n = -10;
os << n;
assert(sb.str() == "fffffffffffffff6");
}
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(unsigned short val);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
unsigned short n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned short n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned short n = 10;
os << n;
assert(sb.str() == "10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
unsigned short n = 0xFFF6;
os << n;
assert(sb.str() == "fff6");
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class charT, class traits>
// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, charT c);
#include <ostream>
#include <cassert>
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()
{
{
std::wostream os((std::wstreambuf*)0);
wchar_t c = L'a';
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
wchar_t c = L'a';
os << c;
assert(sb.str() == L"a");
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
wchar_t c = L'a';
os << c;
assert(sb.str() == L" a");
assert(os.width() == 0);
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
left(os);
wchar_t c = L'a';
os << c;
assert(sb.str() == L"a ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class charT, class traits>
// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const charT* s);
#include <ostream>
#include <cassert>
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()
{
{
std::wostream os((std::wstreambuf*)0);
const wchar_t* c = L"123";
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
const wchar_t* c = L"123";
os << c;
assert(sb.str() == L"123");
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
const wchar_t* c = L"123";
os << c;
assert(sb.str() == L" 123");
assert(os.width() == 0);
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
left(os);
const wchar_t* c = L"123";
os << c;
assert(sb.str() == L"123 ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class char, class traits>
// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, char c);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
char c = 'a';
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
char c = 'a';
os << c;
assert(sb.str() == "a");
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
char c = 'a';
os << c;
assert(sb.str() == " a");
assert(os.width() == 0);
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
left(os);
char c = 'a';
os << c;
assert(sb.str() == "a ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class traits>
// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const char* s);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
const char* c = "123";
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
const char* c = "123";
os << c;
assert(sb.str() == "123");
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
const char* c = "123";
os << c;
assert(sb.str() == " 123");
assert(os.width() == 0);
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
left(os);
const char* c = "123";
os << c;
assert(sb.str() == "123 ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class charT, class traits>
// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, char c);
#include <ostream>
#include <cassert>
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()
{
{
std::wostream os((std::wstreambuf*)0);
char c = 'a';
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
char c = 'a';
os << c;
assert(sb.str() == L"a");
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
char c = 'a';
os << c;
assert(sb.str() == L" a");
assert(os.width() == 0);
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
left(os);
char c = 'a';
os << c;
assert(sb.str() == L"a ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class charT, class traits>
// basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const char* s);
#include <ostream>
#include <cassert>
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()
{
{
std::wostream os((std::wstreambuf*)0);
const char* c = "123";
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
const char* c = "123";
os << c;
assert(sb.str() == L"123");
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
const char* c = "123";
os << c;
assert(sb.str() == L" 123");
assert(os.width() == 0);
}
{
testbuf<wchar_t> sb;
std::wostream os(&sb);
os.width(5);
left(os);
const char* c = "123";
os << c;
assert(sb.str() == L"123 ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class char, class traits>
// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, signed char c);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
signed char c = 'a';
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
signed char c = 'a';
os << c;
assert(sb.str() == "a");
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
signed char c = 'a';
os << c;
assert(sb.str() == " a");
assert(os.width() == 0);
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
left(os);
signed char c = 'a';
os << c;
assert(sb.str() == "a ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class traits>
// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const signed char* s);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
const signed char* c = (const signed char*)"123";
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
const signed char* c = (const signed char*)"123";
os << c;
assert(sb.str() == "123");
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
const signed char* c = (const signed char*)"123";
os << c;
assert(sb.str() == " 123");
assert(os.width() == 0);
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
left(os);
const signed char* c = (const signed char*)"123";
os << c;
assert(sb.str() == "123 ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class char, class traits>
// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, unsigned char c);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
unsigned char c = 'a';
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
unsigned char c = 'a';
os << c;
assert(sb.str() == "a");
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
unsigned char c = 'a';
os << c;
assert(sb.str() == " a");
assert(os.width() == 0);
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
left(os);
unsigned char c = 'a';
os << c;
assert(sb.str() == "a ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// template<class traits>
// basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const unsigned char* s);
#include <ostream>
#include <cassert>
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()
{
{
std::ostream os((std::streambuf*)0);
const unsigned char* c = (const unsigned char*)"123";
os << c;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
const unsigned char* c = (const unsigned char*)"123";
os << c;
assert(sb.str() == "123");
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
const unsigned char* c = (const unsigned char*)"123";
os << c;
assert(sb.str() == " 123");
assert(os.width() == 0);
}
{
testbuf<char> sb;
std::ostream os(&sb);
os.width(5);
left(os);
const unsigned char* c = (const unsigned char*)"123";
os << c;
assert(sb.str() == "123 ");
assert(os.width() == 0);
}
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>&
// (*pf)(basic_ios<charT,traits>&));
#include <ostream>
#include <cassert>
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;
}
};
template <class CharT>
std::basic_ios<CharT>&
f(std::basic_ios<CharT>& os)
{
std::uppercase(os);
return os;
}
int main()
{
{
testbuf<char> sb;
std::ostream os(&sb);
assert(!(os.flags() & std::ios_base::uppercase));
os << f;
assert( (os.flags() & std::ios_base::uppercase));
}
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&));
#include <ostream>
#include <cassert>
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);
assert(!(os.flags() & std::ios_base::uppercase));
os << std::uppercase;
assert( (os.flags() & std::ios_base::uppercase));
}
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// basic_ostream<charT,traits>& operator<<
// (basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&))
#include <ostream>
#include <cassert>
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;
}
};
template <class CharT>
std::basic_ostream<CharT>&
f(std::basic_ostream<CharT>& os)
{
os << "testing...";
return os;
}
int main()
{
{
testbuf<char> sb;
std::ostream os(&sb);
os << f;
assert(sb.str() == "testing...");
}
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// basic_ostream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
#include <ostream>
#include <cassert>
template <class CharT>
class testbuf
: public std::basic_streambuf<CharT>
{
typedef std::basic_streambuf<CharT> base;
std::basic_string<CharT> str_;
public:
testbuf()
{
}
testbuf(const std::basic_string<CharT>& str)
: str_(str)
{
base::setg(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data() + str_.size()));
}
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);
testbuf<char> sb2("testing...");
assert(sb.str() == "");
os << &sb2;
assert(sb.str() == "testing...");
}
}