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:
@@ -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 = char_traits<charT> >
|
||||
// class basic_istream;
|
||||
|
||||
// void swap(basic_istream& rhs);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
struct test_istream
|
||||
: public std::basic_istream<CharT>
|
||||
{
|
||||
typedef std::basic_istream<CharT> base;
|
||||
test_istream(testbuf<CharT>* sb) : base(sb) {}
|
||||
|
||||
void swap(test_istream& s) {base::swap(s);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb1;
|
||||
testbuf<char> sb2;
|
||||
test_istream<char> is1(&sb1);
|
||||
test_istream<char> is2(&sb2);
|
||||
is1.swap(is2);
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb1;
|
||||
testbuf<wchar_t> sb2;
|
||||
test_istream<wchar_t> is1(&sb1);
|
||||
test_istream<wchar_t> is2(&sb2);
|
||||
is1.swap(is2);
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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& operator=(basic_istream&& rhs);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
struct test_istream
|
||||
: public std::basic_istream<CharT>
|
||||
{
|
||||
typedef std::basic_istream<CharT> base;
|
||||
test_istream(testbuf<CharT>* sb) : base(sb) {}
|
||||
|
||||
test_istream& operator=(test_istream&& s)
|
||||
{base::operator=(std::move(s)); return *this;}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
testbuf<char> sb1;
|
||||
testbuf<char> sb2;
|
||||
test_istream<char> is1(&sb1);
|
||||
test_istream<char> is2(&sb2);
|
||||
is2 = (std::move(is1));
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb1;
|
||||
testbuf<wchar_t> sb2;
|
||||
test_istream<wchar_t> is1(&sb1);
|
||||
test_istream<wchar_t> is2(&sb2);
|
||||
is2 = (std::move(is1));
|
||||
assert(is1.rdbuf() == &sb1);
|
||||
assert(is1.tie() == 0);
|
||||
assert(is1.fill() == ' ');
|
||||
assert(is1.rdstate() == is1.goodbit);
|
||||
assert(is1.exceptions() == is1.goodbit);
|
||||
assert(is1.flags() == (is1.skipws | is1.dec));
|
||||
assert(is1.precision() == 6);
|
||||
assert(is1.getloc().name() == "C");
|
||||
assert(is2.rdbuf() == &sb2);
|
||||
assert(is2.tie() == 0);
|
||||
assert(is2.fill() == ' ');
|
||||
assert(is2.rdstate() == is2.goodbit);
|
||||
assert(is2.exceptions() == is2.goodbit);
|
||||
assert(is2.flags() == (is2.skipws | is2.dec));
|
||||
assert(is2.precision() == 6);
|
||||
assert(is2.getloc().name() == "C");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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(basic_istream&& rhs);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
struct test_istream
|
||||
: public std::basic_istream<CharT>
|
||||
{
|
||||
typedef std::basic_istream<CharT> base;
|
||||
test_istream(testbuf<CharT>* sb) : base(sb) {}
|
||||
|
||||
test_istream(test_istream&& s)
|
||||
: base(std::move(s)) {}
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
testbuf<char> sb;
|
||||
test_istream<char> is1(&sb);
|
||||
test_istream<char> is(std::move(is1));
|
||||
assert(is1.rdbuf() == &sb);
|
||||
assert(is1.gcount() == 0);
|
||||
assert(is.gcount() == 0);
|
||||
assert(is.rdbuf() == 0);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == ' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb;
|
||||
test_istream<wchar_t> is1(&sb);
|
||||
test_istream<wchar_t> is(std::move(is1));
|
||||
assert(is1.gcount() == 0);
|
||||
assert(is.gcount() == 0);
|
||||
assert(is1.rdbuf() == &sb);
|
||||
assert(is.rdbuf() == 0);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == L' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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;
|
||||
|
||||
// explicit basic_istream(basic_streambuf<charT,traits>* sb);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_streambuf<CharT>
|
||||
{
|
||||
testbuf() {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb;
|
||||
std::basic_istream<char> is(&sb);
|
||||
assert(is.rdbuf() == &sb);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == ' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
assert(is.gcount() == 0);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb;
|
||||
std::basic_istream<wchar_t> is(&sb);
|
||||
assert(is.rdbuf() == &sb);
|
||||
assert(is.tie() == 0);
|
||||
assert(is.fill() == L' ');
|
||||
assert(is.rdstate() == is.goodbit);
|
||||
assert(is.exceptions() == is.goodbit);
|
||||
assert(is.flags() == (is.skipws | is.dec));
|
||||
assert(is.precision() == 6);
|
||||
assert(is.getloc().name() == "C");
|
||||
assert(is.gcount() == 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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::sentry;
|
||||
|
||||
// explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
|
||||
|
||||
#include <istream>
|
||||
#include <cassert>
|
||||
|
||||
int sync_called = 0;
|
||||
|
||||
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();}
|
||||
protected:
|
||||
|
||||
int virtual sync()
|
||||
{
|
||||
++sync_called;
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream is((testbuf<char>*)0);
|
||||
std::istream::sentry sen(is, true);
|
||||
assert(!(bool)sen);
|
||||
assert(!is.good());
|
||||
assert(is.gcount() == 0);
|
||||
assert(sync_called == 0);
|
||||
}
|
||||
{
|
||||
std::wistream is((testbuf<wchar_t>*)0);
|
||||
std::wistream::sentry sen(is, true);
|
||||
assert(!(bool)sen);
|
||||
assert(!is.good());
|
||||
assert(is.gcount() == 0);
|
||||
assert(sync_called == 0);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123");
|
||||
std::istream is(&sb);
|
||||
std::istream::sentry sen(is, true);
|
||||
assert((bool)sen);
|
||||
assert(is.good());
|
||||
assert(is.gcount() == 0);
|
||||
assert(sync_called == 0);
|
||||
assert(sb.gptr() == sb.eback());
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123");
|
||||
std::wistream is(&sb);
|
||||
std::wistream::sentry sen(is, true);
|
||||
assert((bool)sen);
|
||||
assert(is.good());
|
||||
assert(is.gcount() == 0);
|
||||
assert(sync_called == 0);
|
||||
assert(sb.gptr() == sb.eback());
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" 123");
|
||||
std::istream is(&sb);
|
||||
std::istream::sentry sen(is);
|
||||
assert((bool)sen);
|
||||
assert(is.good());
|
||||
assert(sync_called == 0);
|
||||
assert(sb.gptr() == sb.eback() + 3);
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L" 123");
|
||||
std::wistream is(&sb);
|
||||
std::wistream::sentry sen(is);
|
||||
assert((bool)sen);
|
||||
assert(is.good());
|
||||
assert(sync_called == 0);
|
||||
assert(sb.gptr() == sb.eback() + 3);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
std::istream::sentry sen(is);
|
||||
assert(!(bool)sen);
|
||||
assert(is.fail());
|
||||
assert(is.eof());
|
||||
assert(sync_called == 0);
|
||||
assert(sb.gptr() == sb.eback() + 6);
|
||||
}
|
||||
{
|
||||
testbuf<char> sb(" ");
|
||||
std::istream is(&sb);
|
||||
std::istream::sentry sen(is, true);
|
||||
assert((bool)sen);
|
||||
assert(is.good());
|
||||
assert(sync_called == 0);
|
||||
assert(sb.gptr() == sb.eback());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// : virtual public basic_ios<charT,traits>
|
||||
// {
|
||||
// public:
|
||||
// // types (inherited from basic_ios (27.5.4)):
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef typename traits_type::int_type int_type;
|
||||
// typedef typename traits_type::pos_type pos_type;
|
||||
// typedef typename traits_type::off_type off_type;
|
||||
|
||||
#include <istream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_ios<char>, std::basic_istream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_istream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_istream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_istream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_istream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_istream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
}
|
||||
Reference in New Issue
Block a user