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,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(bool& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
bool n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
bool n = true;
is >> n;
assert(n == false);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 1 ");
std::istream is(&sb);
bool n = 0;
is >> n;
assert(n == true);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" 1 ");
std::wistream is(&sb);
bool n = 0;
is >> n;
assert(n == true);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(double& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
double n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
double n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
double n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" -123.5 ");
std::wistream is(&sb);
double n = 10;
is >> n;
assert(n == -123.5);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(float& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
float n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
float n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
float n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" -123.5 ");
std::wistream is(&sb);
float n = 10;
is >> n;
assert(n == -123.5);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(int& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
int n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
int n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
int n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" -1234567890123456 ");
std::wistream is(&sb);
int n = 10;
is >> n;
assert(n == std::numeric_limits<int>::min());
assert(!is.eof());
assert( is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(long& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
long n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
long n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
long n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" -123 ");
std::wistream is(&sb);
long n = 10;
is >> n;
assert(n == -123);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(long double& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
long double n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
long double n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
long double n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" -123.5 ");
std::wistream is(&sb);
long double n = 10;
is >> n;
assert(n == -123.5);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(long long& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
long long n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
long long n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
long long n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" -123 ");
std::wistream is(&sb);
long long n = 10;
is >> n;
assert(n == -123);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,97 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(void*& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
void* n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
void* n = (void*)1;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 1 ");
std::istream is(&sb);
void* n = 0;
is >> n;
assert(n == (void*)1);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" 1 ");
std::wistream is(&sb);
void* n = 0;
is >> n;
assert(n == (void*)1);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<char> sb("12345678");
std::istream is(&sb);
void* n = 0;
is >> n;
assert(n == (void*)0x12345678);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L"12345678");
std::wistream is(&sb);
void* n = 0;
is >> n;
assert(n == (void*)0x12345678);
assert( is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(short& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
short n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
short n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
short n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" -1234567890 ");
std::wistream is(&sb);
short n = 10;
is >> n;
assert(n == std::numeric_limits<short>::min());
assert(!is.eof());
assert( is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(unsigned int& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
unsigned int n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
unsigned int n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
unsigned int n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" 123 ");
std::wistream is(&sb);
unsigned int n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(unsigned long& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
unsigned long n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
unsigned long n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
unsigned long n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" 123 ");
std::wistream is(&sb);
unsigned long n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(unsigned long long& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
unsigned long long n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
unsigned long long n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
unsigned long long n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" 123 ");
std::wistream is(&sb);
unsigned long long n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
}

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// operator>>(unsigned short& val);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
std::istream is((std::streambuf*)0);
unsigned short n = 0;
is >> n;
assert(is.fail());
}
{
testbuf<char> sb("0");
std::istream is(&sb);
unsigned short n = 10;
is >> n;
assert(n == 0);
assert( is.eof());
assert(!is.fail());
}
{
testbuf<char> sb(" 123 ");
std::istream is(&sb);
unsigned short n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
{
testbuf<wchar_t> sb(L" 123 ");
std::wistream is(&sb);
unsigned short n = 10;
is >> n;
assert(n == 123);
assert(!is.eof());
assert(!is.fail());
}
}

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,38 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// basic_istream<charT,traits>& operator>>(basic_ios<charT,traits>&
// (*pf)(basic_ios<charT,traits>&));
#include <istream>
#include <cassert>
int f_called = 0;
template <class CharT>
std::basic_ios<CharT>&
f(std::basic_ios<CharT>& is)
{
++f_called;
return is;
}
int main()
{
{
std::istream is((std::streambuf*)0);
is >> f;
assert(f_called == 1);
}
}

View File

@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template<class charT, class traits>
// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT& c);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
testbuf<char> sb(" ");
std::istream is(&sb);
char c = 'z';
is >> c;
assert( is.eof());
assert( is.fail());
assert(c == 'z');
}
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
char c;
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'a');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'b');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'c');
}
{
testbuf<wchar_t> sb(L" abc");
std::wistream is(&sb);
wchar_t c;
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == L'a');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == L'b');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == L'c');
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// basic_istream<charT,traits>& operator>>(ios_base& (*pf)(ios_base&));
#include <istream>
#include <cassert>
int f_called = 0;
std::ios_base&
f(std::ios_base& is)
{
++f_called;
return is;
}
int main()
{
{
std::istream is((std::streambuf*)0);
is >> f;
assert(f_called == 1);
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&
// (*pf)(basic_istream<charT,traits>&));
#include <istream>
#include <cassert>
int f_called = 0;
template <class CharT>
std::basic_istream<CharT>&
f(std::basic_istream<CharT>& is)
{
++f_called;
return is;
}
int main()
{
{
std::istream is((std::streambuf*)0);
is >> f;
assert(f_called == 1);
}
}

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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template<class traits>
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char& c);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
testbuf<char> sb(" ");
std::istream is(&sb);
signed char c = 'z';
is >> c;
assert( is.eof());
assert( is.fail());
assert(c == 'z');
}
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
signed char c;
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'a');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'b');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'c');
}
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template<class traits>
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char* s);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
signed char s[20];
is >> s;
assert(!is.eof());
assert(!is.fail());
assert(std::string((char*)s) == "abcdefghijk");
}
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
is.width(4);
signed char s[20];
is >> s;
assert(!is.eof());
assert(!is.fail());
assert(std::string((char*)s) == "abc");
assert(is.width() == 0);
}
{
testbuf<char> sb(" abcdefghijk");
std::istream is(&sb);
signed char s[20];
is >> s;
assert( is.eof());
assert(!is.fail());
assert(std::string((char*)s) == "abcdefghijk");
assert(is.width() == 0);
}
{
testbuf<char> sb(" abcdefghijk");
std::istream is(&sb);
signed char s[20];
is.width(1);
is >> s;
assert(!is.eof());
assert( is.fail());
assert(std::string((char*)s) == "");
assert(is.width() == 0);
}
}

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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template <class charT, class traits = char_traits<charT> >
// class basic_istream;
// basic_istream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
#include <istream>
#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("testing...");
std::istream is(&sb);
testbuf<char> sb2;
is >> &sb2;
assert(sb2.str() == "testing...");
assert(is.gcount() == 10);
}
}

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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template<class traits>
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char& c);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
testbuf<char> sb(" ");
std::istream is(&sb);
unsigned char c = 'z';
is >> c;
assert( is.eof());
assert( is.fail());
assert(c == 'z');
}
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
unsigned char c;
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'a');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'b');
is >> c;
assert(!is.eof());
assert(!is.fail());
assert(c == 'c');
}
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template<class traits>
// basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char* s);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
unsigned char s[20];
is >> s;
assert(!is.eof());
assert(!is.fail());
assert(std::string((char*)s) == "abcdefghijk");
}
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
is.width(4);
unsigned char s[20];
is >> s;
assert(!is.eof());
assert(!is.fail());
assert(std::string((char*)s) == "abc");
assert(is.width() == 0);
}
{
testbuf<char> sb(" abcdefghijk");
std::istream is(&sb);
unsigned char s[20];
is >> s;
assert( is.eof());
assert(!is.fail());
assert(std::string((char*)s) == "abcdefghijk");
assert(is.width() == 0);
}
{
testbuf<char> sb(" abcdefghijk");
std::istream is(&sb);
unsigned char s[20];
is.width(1);
is >> s;
assert(!is.eof());
assert( is.fail());
assert(std::string((char*)s) == "");
assert(is.width() == 0);
}
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <istream>
// template<class charT, class traits>
// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT* s);
#include <istream>
#include <cassert>
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());
}
CharT* eback() const {return base::eback();}
CharT* gptr() const {return base::gptr();}
CharT* egptr() const {return base::egptr();}
};
int main()
{
{
testbuf<char> sb(" abcdefghijk ");
std::istream is(&sb);
char s[20];
is >> s;
assert(!is.eof());
assert(!is.fail());
assert(std::string(s) == "abcdefghijk");
}
{
testbuf<wchar_t> sb(L" abcdefghijk ");
std::wistream is(&sb);
is.width(4);
wchar_t s[20];
is >> s;
assert(!is.eof());
assert(!is.fail());
assert(std::wstring(s) == L"abc");
assert(is.width() == 0);
}
{
testbuf<wchar_t> sb(L" abcdefghijk");
std::wistream is(&sb);
wchar_t s[20];
is >> s;
assert( is.eof());
assert(!is.fail());
assert(std::wstring(s) == L"abcdefghijk");
assert(is.width() == 0);
}
{
testbuf<char> sb(" abcdefghijk");
std::istream is(&sb);
char s[20];
is.width(1);
is >> s;
assert(!is.eof());
assert( is.fail());
assert(std::string(s) == "");
assert(is.width() == 0);
}
}

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()
{
}