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,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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator(const istream_iterator& x);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istream_iterator<int> io;
|
||||
std::istream_iterator<int> i = io;
|
||||
assert(i == std::istream_iterator<int>());
|
||||
}
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> io(inf);
|
||||
std::istream_iterator<int> i = io;
|
||||
assert(i != std::istream_iterator<int>());
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istream_iterator<int> i;
|
||||
assert(i == std::istream_iterator<int>());
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator(istream_type& s);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
assert(i != std::istream_iterator<int>());
|
||||
assert(inf.peek() == ' ');
|
||||
assert(inf.good());
|
||||
int j = 0;
|
||||
inf >> j;
|
||||
assert(j == 23);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// const T* operator->() const;
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
struct A
|
||||
{
|
||||
double d_;
|
||||
int i_;
|
||||
};
|
||||
|
||||
std::istream& operator>>(std::istream& is, A& a)
|
||||
{
|
||||
return is >> a.d_ >> a.i_;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf("1.5 23 ");
|
||||
std::istream_iterator<A> i(inf);
|
||||
assert(i->d_ == 1.5);
|
||||
assert(i->i_ == 23);
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// const T& operator*() const;
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 1);
|
||||
j = *i;
|
||||
assert(j == 1);
|
||||
++i;
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// template <class T, class charT, class traits, class Distance>
|
||||
// bool operator==(const istream_iterator<T,charT,traits,Distance> &x,
|
||||
// const istream_iterator<T,charT,traits,Distance> &y);
|
||||
//
|
||||
// template <class T, class charT, class traits, class Distance>
|
||||
// bool operator!=(const istream_iterator<T,charT,traits,Distance> &x,
|
||||
// const istream_iterator<T,charT,traits,Distance> &y);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf1(" 1 23");
|
||||
std::istringstream inf2(" 1 23");
|
||||
std::istream_iterator<int> i1(inf1);
|
||||
std::istream_iterator<int> i2(inf1);
|
||||
std::istream_iterator<int> i3(inf2);
|
||||
std::istream_iterator<int> i4;
|
||||
std::istream_iterator<int> i5;
|
||||
assert(i1 == i1);
|
||||
assert(i1 == i2);
|
||||
assert(i1 != i3);
|
||||
assert(i1 != i4);
|
||||
assert(i1 != i5);
|
||||
|
||||
assert(i2 == i2);
|
||||
assert(i2 != i3);
|
||||
assert(i2 != i4);
|
||||
assert(i2 != i5);
|
||||
|
||||
assert(i3 == i3);
|
||||
assert(i3 != i4);
|
||||
assert(i3 != i5);
|
||||
|
||||
assert(i4 == i4);
|
||||
assert(i4 == i5);
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator operator++(int);
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
std::istream_iterator<int> icopy = i++;
|
||||
assert(icopy == i);
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
j = 0;
|
||||
j = *icopy;
|
||||
assert(j == 1);
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator& operator++();
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istringstream inf(" 1 23");
|
||||
std::istream_iterator<int> i(inf);
|
||||
std::istream_iterator<int>& iref = ++i;
|
||||
assert(&iref == &i);
|
||||
int j = 0;
|
||||
j = *i;
|
||||
assert(j == 23);
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// template <class T, class charT = char, class traits = char_traits<charT>,
|
||||
// class Distance = ptrdiff_t>
|
||||
// class istream_iterator
|
||||
// : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef traits traits_type;
|
||||
// typedef basic_istream<charT,traits> istream_type;
|
||||
// ...
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::istream_iterator<double> I1;
|
||||
static_assert((std::is_convertible<I1,
|
||||
std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
|
||||
const double*, const double&> >::value), "");
|
||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
|
||||
typedef std::istream_iterator<unsigned, wchar_t> I2;
|
||||
static_assert((std::is_convertible<I2,
|
||||
std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
|
||||
const unsigned*, const unsigned&> >::value), "");
|
||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||
static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
|
||||
}
|
Reference in New Issue
Block a user