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,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
|
||||
// void swap(basic_istringstream& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream ss0(" 123 456");
|
||||
std::istringstream ss(" 789 321");
|
||||
ss.swap(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss0 >> i;
|
||||
assert(i == 789);
|
||||
ss0 >> i;
|
||||
assert(i == 321);
|
||||
}
|
||||
{
|
||||
std::wistringstream ss0(L" 123 456");
|
||||
std::wistringstream ss(L" 789 321");
|
||||
ss.swap(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss0 >> i;
|
||||
assert(i == 789);
|
||||
ss0 >> i;
|
||||
assert(i == 321);
|
||||
}
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
|
||||
// basic_istringstream& operator=(basic_istringstream&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::istringstream ss0(" 123 456");
|
||||
std::istringstream ss;
|
||||
ss = std::move(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
{
|
||||
std::istringstream s1("Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
|
||||
std::string s;
|
||||
s1 >> s;
|
||||
|
||||
std::istringstream s2 = std::move(s1);
|
||||
s2 >> s;
|
||||
assert(s == "Bbbbb");
|
||||
|
||||
std::istringstream s3;
|
||||
s3 = std::move(s2);
|
||||
s3 >> s;
|
||||
assert(s == "Cccccccccc");
|
||||
|
||||
s1 = std::move(s3);
|
||||
s1 >> s;
|
||||
assert(s == "Dddddddddddddddddd");
|
||||
}
|
||||
{
|
||||
std::wistringstream ss0(L" 123 456");
|
||||
std::wistringstream ss;
|
||||
ss = std::move(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
{
|
||||
std::wistringstream s1(L"Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
|
||||
std::wstring s;
|
||||
s1 >> s;
|
||||
|
||||
std::wistringstream s2 = std::move(s1);
|
||||
s2 >> s;
|
||||
assert(s == L"Bbbbb");
|
||||
|
||||
std::wistringstream s3;
|
||||
s3 = std::move(s2);
|
||||
s3 >> s;
|
||||
assert(s == L"Cccccccccc");
|
||||
|
||||
s1 = std::move(s3);
|
||||
s1 >> s;
|
||||
assert(s == L"Dddddddddddddddddd");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
|
||||
// template <class charT, class traits, class Allocator>
|
||||
// void
|
||||
// swap(basic_istringstream<charT, traits, Allocator>& x,
|
||||
// basic_istringstream<charT, traits, Allocator>& y);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream ss0(" 123 456");
|
||||
std::istringstream ss(" 789 321");
|
||||
swap(ss, ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss0 >> i;
|
||||
assert(i == 789);
|
||||
ss0 >> i;
|
||||
assert(i == 321);
|
||||
}
|
||||
{
|
||||
std::wistringstream ss0(L" 123 456");
|
||||
std::wistringstream ss(L" 789 321");
|
||||
swap(ss, ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss0 >> i;
|
||||
assert(i == 789);
|
||||
ss0 >> i;
|
||||
assert(i == 321);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
|
||||
// explicit basic_istringstream(ios_base::openmode which = ios_base::in);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream ss;
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == "");
|
||||
}
|
||||
{
|
||||
std::istringstream ss(std::ios_base::in);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == "");
|
||||
}
|
||||
{
|
||||
std::wistringstream ss;
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L"");
|
||||
}
|
||||
{
|
||||
std::wistringstream ss(std::ios_base::in);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L"");
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
|
||||
// basic_istringstream(basic_istringstream&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::istringstream ss0(" 123 456");
|
||||
std::istringstream ss(std::move(ss0));
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
{
|
||||
std::wistringstream ss0(L" 123 456");
|
||||
std::wistringstream ss(std::move(ss0));
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
|
||||
// explicit basic_istringstream(const basic_string<charT,traits,allocator>& str,
|
||||
// ios_base::openmode which = ios_base::in);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream ss(" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
{
|
||||
std::istringstream ss(" 123 456", std::ios_base::out);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
{
|
||||
std::wistringstream ss(L" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
{
|
||||
std::wistringstream ss(L" 123 456", std::ios_base::out);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
|
||||
// void str(const basic_string<charT,traits,Allocator>& s);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istringstream ss(" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss.str(" 789");
|
||||
ss.clear();
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 789");
|
||||
ss >> i;
|
||||
assert(i == 789);
|
||||
}
|
||||
{
|
||||
std::wistringstream ss(L" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss.str(L" 789");
|
||||
ss.clear();
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 789");
|
||||
ss >> i;
|
||||
assert(i == 789);
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_istringstream
|
||||
// : public basic_istream<charT, traits>
|
||||
// {
|
||||
// public:
|
||||
// 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;
|
||||
// typedef Allocator allocator_type;
|
||||
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_istream<char>, std::basic_istringstream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_istringstream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_istringstream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_istringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_istringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_istringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_istringstream<char>::allocator_type, std::allocator<char> >::value), "");
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
|
||||
// void swap(basic_ostringstream& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream ss0(" 123 456");
|
||||
std::ostringstream ss;
|
||||
ss.swap(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == "234 5676");
|
||||
ss0 << i << ' ' << 567;;
|
||||
assert(ss0.str() == "234 567");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss0(L" 123 456");
|
||||
std::wostringstream ss;
|
||||
ss.swap(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == L"234 5676");
|
||||
ss0 << i << ' ' << 567;;
|
||||
assert(ss0.str() == L"234 567");
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
|
||||
// basic_ostringstream& operator=(basic_ostringstream&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::ostringstream ss0(" 123 456");
|
||||
std::ostringstream ss;
|
||||
ss = std::move(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == "234 5676");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss0(L" 123 456");
|
||||
std::wostringstream ss;
|
||||
ss = std::move(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == L"234 5676");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
|
||||
// void swap(basic_ostringstream& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream ss0(" 123 456");
|
||||
std::ostringstream ss;
|
||||
swap(ss, ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == "234 5676");
|
||||
ss0 << i << ' ' << 567;;
|
||||
assert(ss0.str() == "234 567");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss0(L" 123 456");
|
||||
std::wostringstream ss;
|
||||
swap(ss, ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == L"234 5676");
|
||||
ss0 << i << ' ' << 567;;
|
||||
assert(ss0.str() == L"234 567");
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
|
||||
// explicit basic_ostringstream(ios_base::openmode which = ios_base::in);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream ss;
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == "");
|
||||
}
|
||||
{
|
||||
std::ostringstream ss(std::ios_base::out);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == "");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss;
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L"");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss(std::ios_base::out);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L"");
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
|
||||
// basic_ostringstream(basic_ostringstream&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::ostringstream ss0(" 123 456");
|
||||
std::ostringstream ss(std::move(ss0));
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == "234 5676");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss0(L" 123 456");
|
||||
std::wostringstream ss(std::move(ss0));
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == L"234 5676");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
|
||||
// explicit basic_ostringstream(const basic_string<charT,traits,allocator>& str,
|
||||
// ios_base::openmode which = ios_base::in);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream ss(" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == "234 5676");
|
||||
}
|
||||
{
|
||||
std::ostringstream ss(" 123 456", std::ios_base::in);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == "234 5676");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss(L" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == L"234 5676");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss(L" 123 456", std::ios_base::in);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 234;
|
||||
ss << i << ' ' << 567;;
|
||||
assert(ss.str() == L"234 5676");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
|
||||
// void str(const basic_string<charT,traits,Allocator>& s);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ostringstream ss(" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456");
|
||||
int i = 0;
|
||||
ss << i;
|
||||
assert(ss.str() == "0123 456");
|
||||
ss << 456;
|
||||
assert(ss.str() == "0456 456");
|
||||
ss.str(" 789");
|
||||
assert(ss.str() == " 789");
|
||||
ss << "abc";
|
||||
assert(ss.str() == "abc9");
|
||||
}
|
||||
{
|
||||
std::wostringstream ss(L" 123 456");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456");
|
||||
int i = 0;
|
||||
ss << i;
|
||||
assert(ss.str() == L"0123 456");
|
||||
ss << 456;
|
||||
assert(ss.str() == L"0456 456");
|
||||
ss.str(L" 789");
|
||||
assert(ss.str() == L" 789");
|
||||
ss << L"abc";
|
||||
assert(ss.str() == L"abc9");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_ostringstream
|
||||
// : public basic_ostream<charT, traits>
|
||||
// {
|
||||
// public:
|
||||
// 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;
|
||||
// typedef Allocator allocator_type;
|
||||
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ostringstream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ostringstream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_ostringstream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ostringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ostringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ostringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ostringstream<char>::allocator_type, std::allocator<char> >::value), "");
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// void swap(basic_stringbuf& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf buf1("testing");
|
||||
std::stringbuf buf;
|
||||
buf.swap(buf1);
|
||||
assert(buf.str() == "testing");
|
||||
assert(buf1.str() == "");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::in);
|
||||
std::stringbuf buf;
|
||||
buf.swap(buf1);
|
||||
assert(buf.str() == "testing");
|
||||
assert(buf1.str() == "");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::out);
|
||||
std::stringbuf buf;
|
||||
buf.swap(buf1);
|
||||
assert(buf.str() == "testing");
|
||||
assert(buf1.str() == "");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing");
|
||||
std::wstringbuf buf;
|
||||
buf.swap(buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
assert(buf1.str() == L"");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::in);
|
||||
std::wstringbuf buf;
|
||||
buf.swap(buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
assert(buf1.str() == L"");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::out);
|
||||
std::wstringbuf buf;
|
||||
buf.swap(buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
assert(buf1.str() == L"");
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// basic_stringbuf& operator=(basic_stringbuf&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf buf1("testing");
|
||||
std::stringbuf buf;
|
||||
buf = move(buf1);
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::in);
|
||||
std::stringbuf buf;
|
||||
buf = move(buf1);
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::out);
|
||||
std::stringbuf buf;
|
||||
buf = move(buf1);
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing");
|
||||
std::wstringbuf buf;
|
||||
buf = move(buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::in);
|
||||
std::wstringbuf buf;
|
||||
buf = move(buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::out);
|
||||
std::wstringbuf buf;
|
||||
buf = move(buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// template <class charT, class traits, class Allocator>
|
||||
// void swap(basic_stringbuf<charT, traits, Allocator>& x,
|
||||
// basic_stringbuf<charT, traits, Allocator>& y);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf buf1("testing");
|
||||
std::stringbuf buf;
|
||||
swap(buf, buf1);
|
||||
assert(buf.str() == "testing");
|
||||
assert(buf1.str() == "");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::in);
|
||||
std::stringbuf buf;
|
||||
swap(buf, buf1);
|
||||
assert(buf.str() == "testing");
|
||||
assert(buf1.str() == "");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::out);
|
||||
std::stringbuf buf;
|
||||
swap(buf, buf1);
|
||||
assert(buf.str() == "testing");
|
||||
assert(buf1.str() == "");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing");
|
||||
std::wstringbuf buf;
|
||||
swap(buf, buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
assert(buf1.str() == L"");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::in);
|
||||
std::wstringbuf buf;
|
||||
swap(buf, buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
assert(buf1.str() == L"");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::out);
|
||||
std::wstringbuf buf;
|
||||
swap(buf, buf1);
|
||||
assert(buf.str() == L"testing");
|
||||
assert(buf1.str() == L"");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf buf;
|
||||
assert(buf.str() == "");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf;
|
||||
assert(buf.str() == L"");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// basic_stringbuf(basic_stringbuf&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf buf1("testing");
|
||||
std::stringbuf buf(move(buf1));
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::in);
|
||||
std::stringbuf buf(move(buf1));
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf1("testing", std::ios_base::out);
|
||||
std::stringbuf buf(move(buf1));
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing");
|
||||
std::wstringbuf buf(move(buf1));
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::in);
|
||||
std::wstringbuf buf(move(buf1));
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf1(L"testing", std::ios_base::out);
|
||||
std::wstringbuf buf(move(buf1));
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// explicit basic_stringbuf(const basic_string<charT,traits,Allocator>& s,
|
||||
// ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf buf("testing");
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf("testing", std::ios_base::in);
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::stringbuf buf("testing", std::ios_base::out);
|
||||
assert(buf.str() == "testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf(L"testing");
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf(L"testing", std::ios_base::in);
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf(L"testing", std::ios_base::out);
|
||||
assert(buf.str() == L"testing");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// void str(const basic_string<charT,traits,Allocator>& s);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf buf("testing");
|
||||
assert(buf.str() == "testing");
|
||||
buf.str("another test");
|
||||
assert(buf.str() == "another test");
|
||||
}
|
||||
{
|
||||
std::wstringbuf buf(L"testing");
|
||||
assert(buf.str() == L"testing");
|
||||
buf.str(L"another test");
|
||||
assert(buf.str() == L"another test");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// int_type overflow(int_type c = traits::eof());
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int overflow_called = 0;
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_stringbuf<CharT>
|
||||
{
|
||||
typedef std::basic_stringbuf<CharT> base;
|
||||
explicit testbuf(const std::basic_string<CharT>& str,
|
||||
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
|
||||
: base(str, which) {}
|
||||
|
||||
typename base::int_type
|
||||
overflow(typename base::int_type c = base::type_traits::eof())
|
||||
{++overflow_called; return base::overflow(c);}
|
||||
|
||||
void pbump(int n) {base::pbump(n);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb("abc");
|
||||
assert(sb.sputc('1') == '1');
|
||||
assert(sb.str() == "1bc");
|
||||
assert(sb.sputc('2') == '2');
|
||||
assert(sb.str() == "12c");
|
||||
assert(sb.sputc('3') == '3');
|
||||
assert(sb.str() == "123");
|
||||
assert(sb.sputc('4') == '4');
|
||||
assert(sb.str() == "1234");
|
||||
assert(sb.sputc('5') == '5');
|
||||
assert(sb.str() == "12345");
|
||||
assert(sb.sputc('6') == '6');
|
||||
assert(sb.str() == "123456");
|
||||
assert(sb.sputc('7') == '7');
|
||||
assert(sb.str() == "1234567");
|
||||
assert(sb.sputc('8') == '8');
|
||||
assert(sb.str() == "12345678");
|
||||
assert(sb.sputc('9') == '9');
|
||||
assert(sb.str() == "123456789");
|
||||
assert(sb.sputc('0') == '0');
|
||||
assert(sb.str() == "1234567890");
|
||||
assert(sb.sputc('1') == '1');
|
||||
assert(sb.str() == "12345678901");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L"abc");
|
||||
assert(sb.sputc(L'1') == L'1');
|
||||
assert(sb.str() == L"1bc");
|
||||
assert(sb.sputc(L'2') == L'2');
|
||||
assert(sb.str() == L"12c");
|
||||
assert(sb.sputc(L'3') == L'3');
|
||||
assert(sb.str() == L"123");
|
||||
assert(sb.sputc(L'4') == L'4');
|
||||
assert(sb.str() == L"1234");
|
||||
assert(sb.sputc(L'5') == L'5');
|
||||
assert(sb.str() == L"12345");
|
||||
assert(sb.sputc(L'6') == L'6');
|
||||
assert(sb.str() == L"123456");
|
||||
assert(sb.sputc(L'7') == L'7');
|
||||
assert(sb.str() == L"1234567");
|
||||
assert(sb.sputc(L'8') == L'8');
|
||||
assert(sb.str() == L"12345678");
|
||||
assert(sb.sputc(L'9') == L'9');
|
||||
assert(sb.str() == L"123456789");
|
||||
assert(sb.sputc(L'0') == L'0');
|
||||
assert(sb.str() == L"1234567890");
|
||||
assert(sb.sputc(L'1') == L'1');
|
||||
assert(sb.str() == L"12345678901");
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("abc", std::ios_base::app | std::ios_base::out);
|
||||
assert(sb.sputc('1') == '1');
|
||||
assert(sb.str() == "abc1");
|
||||
assert(sb.sputc('2') == '2');
|
||||
assert(sb.str() == "abc12");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// int_type pbackfail(int_type c = traits::eof());
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_stringbuf<CharT>
|
||||
{
|
||||
typedef std::basic_stringbuf<CharT> base;
|
||||
explicit testbuf(const std::basic_string<CharT>& str,
|
||||
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
|
||||
: base(str, which) {}
|
||||
|
||||
typename base::int_type
|
||||
pbackfail(typename base::int_type c = base::type_traits::eof())
|
||||
{return base::pbackfail(c);}
|
||||
|
||||
void pbump(int n) {base::pbump(n);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb("123", std::ios_base::in);
|
||||
assert(sb.sgetc() == '1');
|
||||
assert(sb.snextc() == '2');
|
||||
assert(sb.snextc() == '3');
|
||||
assert(sb.sgetc() == '3');
|
||||
assert(sb.snextc() == std::char_traits<char>::eof());
|
||||
assert(sb.pbackfail('3') == '3');
|
||||
assert(sb.pbackfail('3') == std::char_traits<char>::eof());
|
||||
assert(sb.pbackfail('2') == '2');
|
||||
assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
|
||||
assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
|
||||
assert(sb.str() == "123");
|
||||
}
|
||||
{
|
||||
testbuf<char> sb("123");
|
||||
assert(sb.sgetc() == '1');
|
||||
assert(sb.snextc() == '2');
|
||||
assert(sb.snextc() == '3');
|
||||
assert(sb.sgetc() == '3');
|
||||
assert(sb.snextc() == std::char_traits<char>::eof());
|
||||
assert(sb.pbackfail('3') == '3');
|
||||
assert(sb.pbackfail('3') == '3');
|
||||
assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
|
||||
assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
|
||||
assert(sb.str() == "133");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L"123", std::ios_base::in);
|
||||
assert(sb.sgetc() == L'1');
|
||||
assert(sb.snextc() == L'2');
|
||||
assert(sb.snextc() == L'3');
|
||||
assert(sb.sgetc() == L'3');
|
||||
assert(sb.snextc() == std::char_traits<wchar_t>::eof());
|
||||
assert(sb.pbackfail(L'3') == L'3');
|
||||
assert(sb.pbackfail(L'3') == std::char_traits<wchar_t>::eof());
|
||||
assert(sb.pbackfail(L'2') == L'2');
|
||||
assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
|
||||
assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
|
||||
assert(sb.str() == L"123");
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L"123");
|
||||
assert(sb.sgetc() == L'1');
|
||||
assert(sb.snextc() == L'2');
|
||||
assert(sb.snextc() == L'3');
|
||||
assert(sb.sgetc() == L'3');
|
||||
assert(sb.snextc() == std::char_traits<wchar_t>::eof());
|
||||
assert(sb.pbackfail(L'3') == L'3');
|
||||
assert(sb.pbackfail(L'3') == L'3');
|
||||
assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
|
||||
assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
|
||||
assert(sb.str() == L"133");
|
||||
}
|
||||
}
|
@@ -0,0 +1,143 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// pos_type seekoff(off_type off, ios_base::seekdir way,
|
||||
// ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf sb("0123456789", std::ios_base::in);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == '3');
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
|
||||
assert(sb.sgetc() == '6');
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
|
||||
assert(sb.sgetc() == '7');
|
||||
}
|
||||
{
|
||||
std::stringbuf sb("0123456789", std::ios_base::out);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
|
||||
assert(sb.sputc('a') == 'a');
|
||||
assert(sb.str() == "012a456789");
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
|
||||
assert(sb.sputc('b') == 'b');
|
||||
assert(sb.str() == "012a456b89");
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
|
||||
assert(sb.sputc('c') == 'c');
|
||||
assert(sb.str() == "012a456c89");
|
||||
}
|
||||
{
|
||||
std::stringbuf sb("0123456789");
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == '3');
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
|
||||
assert(sb.sgetc() == '6');
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
|
||||
assert(sb.sgetc() == '7');
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == '3');
|
||||
assert(sb.sputc('a') == 'a');
|
||||
assert(sb.str() == "012a456789");
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
|
||||
assert(sb.sgetc() == '7');
|
||||
assert(sb.sputc('c') == 'c');
|
||||
assert(sb.str() == "012a456c89");
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
|
||||
assert(sb.sputc('3') == '3');
|
||||
assert(sb.str() == "0123456c89");
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
|
||||
assert(sb.sputc('7') == '7');
|
||||
assert(sb.str() == "0123456789");
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
|
||||
assert(sb.sputc('c') == 'c');
|
||||
assert(sb.str() == "0123456c89");
|
||||
}
|
||||
{
|
||||
std::wstringbuf sb(L"0123456789", std::ios_base::in);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == L'3');
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
|
||||
assert(sb.sgetc() == L'6');
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
|
||||
assert(sb.sgetc() == L'7');
|
||||
}
|
||||
{
|
||||
std::wstringbuf sb(L"0123456789", std::ios_base::out);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
|
||||
assert(sb.sputc(L'a') == L'a');
|
||||
assert(sb.str() == L"012a456789");
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
|
||||
assert(sb.sputc(L'b') == L'b');
|
||||
assert(sb.str() == L"012a456b89");
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
|
||||
assert(sb.sputc(L'c') == L'c');
|
||||
assert(sb.str() == L"012a456c89");
|
||||
}
|
||||
{
|
||||
std::wstringbuf sb(L"0123456789");
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == L'3');
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
|
||||
assert(sb.sgetc() == L'6');
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
|
||||
assert(sb.sgetc() == L'7');
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == L'3');
|
||||
assert(sb.sputc(L'a') == L'a');
|
||||
assert(sb.str() == L"012a456789");
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
|
||||
assert(sb.sgetc() == L'7');
|
||||
assert(sb.sputc(L'c') == L'c');
|
||||
assert(sb.str() == L"012a456c89");
|
||||
assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
|
||||
assert(sb.sputc(L'3') == L'3');
|
||||
assert(sb.str() == L"0123456c89");
|
||||
assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
|
||||
assert(sb.sputc(L'7') == L'7');
|
||||
assert(sb.str() == L"0123456789");
|
||||
assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
|
||||
assert(sb.sputc(L'c') == L'c');
|
||||
assert(sb.str() == L"0123456c89");
|
||||
}
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// pos_type seekpos(pos_type sp,
|
||||
// ios_base::openmode which = ios_base::in | ios_base::out);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf sb("0123456789", std::ios_base::in);
|
||||
assert(sb.pubseekpos(3, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == '3');
|
||||
}
|
||||
{
|
||||
std::stringbuf sb("0123456789", std::ios_base::out);
|
||||
assert(sb.pubseekpos(3, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::out) == 3);
|
||||
assert(sb.sputc('a') == 'a');
|
||||
assert(sb.str() == "012a456789");
|
||||
}
|
||||
{
|
||||
std::stringbuf sb("0123456789");
|
||||
assert(sb.pubseekpos(3, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == '3');
|
||||
assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == '3');
|
||||
assert(sb.sputc('a') == 'a');
|
||||
assert(sb.str() == "012a456789");
|
||||
assert(sb.pubseekpos(3, std::ios_base::out) == 3);
|
||||
assert(sb.sputc('3') == '3');
|
||||
assert(sb.str() == "0123456789");
|
||||
}
|
||||
{
|
||||
std::wstringbuf sb(L"0123456789", std::ios_base::in);
|
||||
assert(sb.pubseekpos(3, std::ios_base::out) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == L'3');
|
||||
}
|
||||
{
|
||||
std::wstringbuf sb(L"0123456789", std::ios_base::out);
|
||||
assert(sb.pubseekpos(3, std::ios_base::in) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
|
||||
assert(sb.pubseekpos(3, std::ios_base::out) == 3);
|
||||
assert(sb.sputc(L'a') == L'a');
|
||||
assert(sb.str() == L"012a456789");
|
||||
}
|
||||
{
|
||||
std::wstringbuf sb(L"0123456789");
|
||||
assert(sb.pubseekpos(3, std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == L'3');
|
||||
assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
|
||||
assert(sb.sgetc() == L'3');
|
||||
assert(sb.sputc(L'a') == L'a');
|
||||
assert(sb.str() == L"012a456789");
|
||||
assert(sb.pubseekpos(3, std::ios_base::out) == 3);
|
||||
assert(sb.sputc(L'3') == L'3');
|
||||
assert(sb.str() == L"0123456789");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// basic_streambuf<charT,traits>* setbuf(charT* s, streamsize n);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringbuf sb("0123456789");
|
||||
assert(sb.pubsetbuf(0, 0) == &sb);
|
||||
assert(sb.str() == "0123456789");
|
||||
}
|
||||
{
|
||||
std::wstringbuf sb(L"0123456789");
|
||||
assert(sb.pubsetbuf(0, 0) == &sb);
|
||||
assert(sb.str() == L"0123456789");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
|
||||
// int_type underflow();
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
struct testbuf
|
||||
: public std::basic_stringbuf<CharT>
|
||||
{
|
||||
typedef std::basic_stringbuf<CharT> base;
|
||||
explicit testbuf(const std::basic_string<CharT>& str)
|
||||
: base(str) {}
|
||||
|
||||
typename base::int_type underflow() {return base::underflow();}
|
||||
void pbump(int n) {base::pbump(n);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
testbuf<char> sb("123");
|
||||
sb.pbump(3);
|
||||
assert(sb.underflow() == '1');
|
||||
assert(sb.underflow() == '1');
|
||||
assert(sb.snextc() == '2');
|
||||
assert(sb.underflow() == '2');
|
||||
assert(sb.underflow() == '2');
|
||||
assert(sb.snextc() == '3');
|
||||
assert(sb.underflow() == '3');
|
||||
assert(sb.underflow() == '3');
|
||||
assert(sb.snextc() == std::char_traits<char>::eof());
|
||||
assert(sb.underflow() == std::char_traits<char>::eof());
|
||||
assert(sb.underflow() == std::char_traits<char>::eof());
|
||||
sb.sputc('4');
|
||||
assert(sb.underflow() == '4');
|
||||
assert(sb.underflow() == '4');
|
||||
}
|
||||
{
|
||||
testbuf<wchar_t> sb(L"123");
|
||||
sb.pbump(3);
|
||||
assert(sb.underflow() == L'1');
|
||||
assert(sb.underflow() == L'1');
|
||||
assert(sb.snextc() == L'2');
|
||||
assert(sb.underflow() == L'2');
|
||||
assert(sb.underflow() == L'2');
|
||||
assert(sb.snextc() == L'3');
|
||||
assert(sb.underflow() == L'3');
|
||||
assert(sb.underflow() == L'3');
|
||||
assert(sb.snextc() == std::char_traits<wchar_t>::eof());
|
||||
assert(sb.underflow() == std::char_traits<wchar_t>::eof());
|
||||
assert(sb.underflow() == std::char_traits<wchar_t>::eof());
|
||||
sb.sputc(L'4');
|
||||
assert(sb.underflow() == L'4');
|
||||
assert(sb.underflow() == L'4');
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringbuf
|
||||
// : public basic_streambuf<charT, traits>
|
||||
// {
|
||||
// public:
|
||||
// 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;
|
||||
// typedef Allocator allocator_type;
|
||||
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_stringbuf<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_stringbuf<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringbuf<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_stringbuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringbuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringbuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringbuf<char>::allocator_type, std::allocator<char> >::value), "");
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringstream ss;
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == "");
|
||||
}
|
||||
{
|
||||
std::stringstream ss(std::ios_base::in);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == "");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss;
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L"");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss(std::ios_base::in);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L"");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// basic_stringstream(basic_stringstream&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::stringstream ss0(" 123 456 ");
|
||||
std::stringstream ss(std::move(ss0));
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == "456 1236 ");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss0(L" 123 456 ");
|
||||
std::wstringstream ss(std::move(ss0));
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == L"456 1236 ");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// basic_stringstream(basic_stringstream&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
std::vector<std::istringstream> vecis;
|
||||
vecis.push_back(std::istringstream());
|
||||
vecis.back().str("hub started at [00 6b 8b 45 69]");
|
||||
vecis.push_back(std::istringstream());
|
||||
vecis.back().str("hub started at [00 6b 8b 45 69]");
|
||||
for (int n = 0; n < vecis.size(); n++)
|
||||
{
|
||||
assert(vecis[n].str().size() == 31);
|
||||
vecis[n].seekg(0, std::ios_base::beg);
|
||||
assert(vecis[n].str().size() == 31);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// explicit basic_stringstream(const basic_string<charT,traits,Allocator>& str,
|
||||
// ios_base::openmode which = ios_base::out|ios_base::in);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringstream ss(" 123 456 ");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == "456 1236 ");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss(L" 123 456 ");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == L"456 1236 ");
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// void swap(basic_stringstream& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringstream ss0(" 123 456 ");
|
||||
std::stringstream ss;
|
||||
ss.swap(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == "456 1236 ");
|
||||
ss0 << i << ' ' << 123;
|
||||
assert(ss0.str() == "456 123");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss0(L" 123 456 ");
|
||||
std::wstringstream ss;
|
||||
ss.swap(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == L"456 1236 ");
|
||||
ss0 << i << ' ' << 123;
|
||||
assert(ss0.str() == L"456 123");
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// basic_stringstream& operator=(basic_stringstream&& rhs);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
std::stringstream ss0(" 123 456 ");
|
||||
std::stringstream ss;
|
||||
ss = std::move(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == "456 1236 ");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss0(L" 123 456 ");
|
||||
std::wstringstream ss;
|
||||
ss = std::move(ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == L"456 1236 ");
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// template <class charT, class traits, class Allocator>
|
||||
// void
|
||||
// swap(basic_stringstream<charT, traits, Allocator>& x,
|
||||
// basic_stringstream<charT, traits, Allocator>& y);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringstream ss0(" 123 456 ");
|
||||
std::stringstream ss;
|
||||
swap(ss, ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == "456 1236 ");
|
||||
ss0 << i << ' ' << 123;
|
||||
assert(ss0.str() == "456 123");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss0(L" 123 456 ");
|
||||
std::wstringstream ss;
|
||||
swap(ss, ss0);
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == L"456 1236 ");
|
||||
ss0 << i << ' ' << 123;
|
||||
assert(ss0.str() == L"456 123");
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
|
||||
// void str(const basic_string<charT,traits,Allocator>& str);
|
||||
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::stringstream ss(" 123 456 ");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == " 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == "456 1236 ");
|
||||
ss.str("5466 89 ");
|
||||
ss >> i;
|
||||
assert(i == 5466);
|
||||
ss >> i;
|
||||
assert(i == 89);
|
||||
ss << i << ' ' << 321;
|
||||
assert(ss.str() == "89 3219 ");
|
||||
}
|
||||
{
|
||||
std::wstringstream ss(L" 123 456 ");
|
||||
assert(ss.rdbuf() != 0);
|
||||
assert(ss.good());
|
||||
assert(ss.str() == L" 123 456 ");
|
||||
int i = 0;
|
||||
ss >> i;
|
||||
assert(i == 123);
|
||||
ss >> i;
|
||||
assert(i == 456);
|
||||
ss << i << ' ' << 123;
|
||||
assert(ss.str() == L"456 1236 ");
|
||||
ss.str(L"5466 89 ");
|
||||
ss >> i;
|
||||
assert(i == 5466);
|
||||
ss >> i;
|
||||
assert(i == 89);
|
||||
ss << i << ' ' << 321;
|
||||
assert(ss.str() == L"89 3219 ");
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
|
||||
// class basic_stringstream
|
||||
// : public basic_iostream<charT, traits>
|
||||
// {
|
||||
// public:
|
||||
// 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;
|
||||
// typedef Allocator allocator_type;
|
||||
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_stringstream<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_stringstream<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringstream<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_stringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_stringstream<char>::allocator_type, std::allocator<char> >::value), "");
|
||||
}
|
20
test/std/input.output/string.streams/version.pass.cpp
Normal file
20
test/std/input.output/string.streams/version.pass.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <sstream>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#ifndef _LIBCPP_VERSION
|
||||
#error _LIBCPP_VERSION not defined
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user