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,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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// explicit basic_ios(basic_streambuf<charT,traits>* sb);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::streambuf* sb = 0;
|
||||
std::basic_ios<char> ios(sb);
|
||||
assert(ios.rdbuf() == sb);
|
||||
assert(ios.tie() == 0);
|
||||
assert(ios.rdstate() == std::ios::badbit);
|
||||
assert(ios.exceptions() == std::ios::goodbit);
|
||||
assert(ios.flags() == (std::ios::skipws | std::ios::dec));
|
||||
assert(ios.width() == 0);
|
||||
assert(ios.precision() == 6);
|
||||
assert(ios.fill() == ' ');
|
||||
assert(ios.getloc() == std::locale());
|
||||
}
|
||||
{
|
||||
std::streambuf* sb = (std::streambuf*)1;
|
||||
std::basic_ios<char> ios(sb);
|
||||
assert(ios.rdbuf() == sb);
|
||||
assert(ios.tie() == 0);
|
||||
assert(ios.rdstate() == std::ios::goodbit);
|
||||
assert(ios.exceptions() == std::ios::goodbit);
|
||||
assert(ios.flags() == (std::ios::skipws | std::ios::dec));
|
||||
assert(ios.width() == 0);
|
||||
assert(ios.precision() == 6);
|
||||
assert(ios.fill() == ' ');
|
||||
assert(ios.getloc() == std::locale());
|
||||
}
|
||||
}
|
@@ -0,0 +1,190 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: locale.en_US.UTF-8
|
||||
// REQUIRES: locale.fr_FR.UTF-8
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// basic_ios& copyfmt(const basic_ios& rhs);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
struct testbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
};
|
||||
|
||||
bool f1_called = false;
|
||||
bool f2_called = false;
|
||||
|
||||
bool g1_called = false;
|
||||
bool g2_called = false;
|
||||
bool g3_called = false;
|
||||
|
||||
void f1(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::erase_event)
|
||||
{
|
||||
assert(!f1_called);
|
||||
assert( f2_called);
|
||||
assert(!g1_called);
|
||||
assert(!g2_called);
|
||||
assert(!g3_called);
|
||||
assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
|
||||
assert(index == 4);
|
||||
f1_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void f2(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::erase_event)
|
||||
{
|
||||
assert(!f1_called);
|
||||
assert(!f2_called);
|
||||
assert(!g1_called);
|
||||
assert(!g2_called);
|
||||
assert(!g3_called);
|
||||
assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
|
||||
assert(index == 5);
|
||||
f2_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void g1(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::copyfmt_event)
|
||||
{
|
||||
assert( f1_called);
|
||||
assert( f2_called);
|
||||
assert(!g1_called);
|
||||
assert( g2_called);
|
||||
assert( g3_called);
|
||||
assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
|
||||
assert(index == 7);
|
||||
g1_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void g2(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::copyfmt_event)
|
||||
{
|
||||
assert( f1_called);
|
||||
assert( f2_called);
|
||||
assert(!g1_called);
|
||||
assert(!g2_called);
|
||||
assert( g3_called);
|
||||
assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
|
||||
assert(index == 8);
|
||||
g2_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void g3(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::copyfmt_event)
|
||||
{
|
||||
assert( f1_called);
|
||||
assert( f2_called);
|
||||
assert(!g1_called);
|
||||
assert(!g2_called);
|
||||
assert(!g3_called);
|
||||
assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
|
||||
assert(index == 9);
|
||||
g3_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
testbuf sb1;
|
||||
std::ios ios1(&sb1);
|
||||
ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
|
||||
ios1.precision(1);
|
||||
ios1.width(11);
|
||||
ios1.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
ios1.exceptions(std::ios::failbit);
|
||||
ios1.setstate(std::ios::eofbit);
|
||||
ios1.register_callback(f1, 4);
|
||||
ios1.register_callback(f2, 5);
|
||||
ios1.iword(0) = 1;
|
||||
ios1.iword(1) = 2;
|
||||
ios1.iword(2) = 3;
|
||||
char c1, c2, c3;
|
||||
ios1.pword(0) = &c1;
|
||||
ios1.pword(1) = &c2;
|
||||
ios1.pword(2) = &c3;
|
||||
ios1.tie((std::ostream*)1);
|
||||
ios1.fill('1');
|
||||
|
||||
testbuf sb2;
|
||||
std::ios ios2(&sb2);
|
||||
ios2.flags(std::ios::showpoint | std::ios::uppercase);
|
||||
ios2.precision(2);
|
||||
ios2.width(12);
|
||||
ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
|
||||
ios2.exceptions(std::ios::eofbit);
|
||||
ios2.setstate(std::ios::goodbit);
|
||||
ios2.register_callback(g1, 7);
|
||||
ios2.register_callback(g2, 8);
|
||||
ios2.register_callback(g3, 9);
|
||||
ios2.iword(0) = 4;
|
||||
ios2.iword(1) = 5;
|
||||
ios2.iword(2) = 6;
|
||||
ios2.iword(3) = 7;
|
||||
ios2.iword(4) = 8;
|
||||
ios2.iword(5) = 9;
|
||||
char d1, d2;
|
||||
ios2.pword(0) = &d1;
|
||||
ios2.pword(1) = &d2;
|
||||
ios2.tie((std::ostream*)2);
|
||||
ios2.fill('2');
|
||||
|
||||
ios1.copyfmt(ios1);
|
||||
assert(!f1_called);
|
||||
|
||||
try
|
||||
{
|
||||
ios1.copyfmt(ios2);
|
||||
assert(false);
|
||||
}
|
||||
catch (std::ios_base::failure&)
|
||||
{
|
||||
}
|
||||
assert(ios1.rdstate() == std::ios::eofbit);
|
||||
assert(ios1.rdbuf() == &sb1);
|
||||
assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
|
||||
assert(ios1.precision() == 2);
|
||||
assert(ios1.width() == 12);
|
||||
assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
|
||||
assert(ios1.exceptions() == std::ios::eofbit);
|
||||
assert(f1_called);
|
||||
assert(f2_called);
|
||||
assert(g1_called);
|
||||
assert(g2_called);
|
||||
assert(g3_called);
|
||||
assert(ios1.iword(0) == 4);
|
||||
assert(ios1.iword(1) == 5);
|
||||
assert(ios1.iword(2) == 6);
|
||||
assert(ios1.iword(3) == 7);
|
||||
assert(ios1.iword(4) == 8);
|
||||
assert(ios1.iword(5) == 9);
|
||||
assert(ios1.pword(0) == &d1);
|
||||
assert(ios1.pword(1) == &d2);
|
||||
assert(ios1.tie() == (std::ostream*)2);
|
||||
assert(ios1.fill() == '2');
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// char_type fill() const;
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::ios ios(0);
|
||||
assert(ios.fill() == ' ');
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// char_type fill(char_type fillch);
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(ios.fill() == ' ');
|
||||
char c = ios.fill('*');
|
||||
assert(c == ' ');
|
||||
assert(ios.fill() == '*');
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// locale imbue(const locale& loc);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
struct testbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
};
|
||||
|
||||
bool f1_called = false;
|
||||
bool f2_called = false;
|
||||
bool f3_called = false;
|
||||
|
||||
void f1(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::imbue_event)
|
||||
{
|
||||
assert(!f1_called);
|
||||
assert( f2_called);
|
||||
assert( f3_called);
|
||||
assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
|
||||
assert(index == 4);
|
||||
f1_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void f2(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::imbue_event)
|
||||
{
|
||||
assert(!f1_called);
|
||||
assert(!f2_called);
|
||||
assert( f3_called);
|
||||
assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
|
||||
assert(index == 5);
|
||||
f2_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void f3(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::imbue_event)
|
||||
{
|
||||
assert(!f1_called);
|
||||
assert(!f2_called);
|
||||
assert(!f3_called);
|
||||
assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
|
||||
assert(index == 6);
|
||||
f3_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
ios.register_callback(f1, 4);
|
||||
ios.register_callback(f2, 5);
|
||||
ios.register_callback(f3, 6);
|
||||
std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
assert(l.name() == std::string("C"));
|
||||
assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
|
||||
assert(f1_called);
|
||||
assert(f2_called);
|
||||
assert(f3_called);
|
||||
}
|
||||
f1_called = false;
|
||||
f2_called = false;
|
||||
f3_called = false;
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
ios.register_callback(f1, 4);
|
||||
ios.register_callback(f2, 5);
|
||||
ios.register_callback(f3, 6);
|
||||
std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
assert(l.name() == std::string("C"));
|
||||
assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
|
||||
assert(sb.getloc().name() == std::string(LOCALE_en_US_UTF_8));
|
||||
assert(f1_called);
|
||||
assert(f2_called);
|
||||
assert(f3_called);
|
||||
}
|
||||
}
|
@@ -0,0 +1,140 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: locale.fr_FR.UTF-8
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// void move(basic_ios&& rhs);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
struct testbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
};
|
||||
|
||||
struct testios
|
||||
: public std::ios
|
||||
{
|
||||
testios() {}
|
||||
testios(std::streambuf* p) : std::ios(p) {}
|
||||
void move(std::ios& x) {std::ios::move(x);}
|
||||
};
|
||||
|
||||
bool f1_called = false;
|
||||
bool f2_called = false;
|
||||
|
||||
bool g1_called = false;
|
||||
bool g2_called = false;
|
||||
bool g3_called = false;
|
||||
|
||||
void f1(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
f1_called = true;
|
||||
}
|
||||
|
||||
void f2(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
f2_called = true;
|
||||
}
|
||||
|
||||
void g1(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::imbue_event)
|
||||
{
|
||||
assert(index == 7);
|
||||
g1_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void g2(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::imbue_event)
|
||||
{
|
||||
assert(index == 8);
|
||||
g2_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
void g3(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
if (ev == std::ios_base::imbue_event)
|
||||
{
|
||||
assert(index == 9);
|
||||
g3_called = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
testios ios1;
|
||||
testbuf sb2;
|
||||
std::ios ios2(&sb2);
|
||||
ios2.flags(std::ios::showpoint | std::ios::uppercase);
|
||||
ios2.precision(2);
|
||||
ios2.width(12);
|
||||
ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
|
||||
ios2.exceptions(std::ios::eofbit);
|
||||
ios2.setstate(std::ios::goodbit);
|
||||
ios2.register_callback(g1, 7);
|
||||
ios2.register_callback(g2, 8);
|
||||
ios2.register_callback(g3, 9);
|
||||
ios2.iword(0) = 4;
|
||||
ios2.iword(1) = 5;
|
||||
ios2.iword(2) = 6;
|
||||
ios2.iword(3) = 7;
|
||||
ios2.iword(4) = 8;
|
||||
ios2.iword(5) = 9;
|
||||
char d1, d2;
|
||||
ios2.pword(0) = &d1;
|
||||
ios2.pword(1) = &d2;
|
||||
ios2.tie((std::ostream*)2);
|
||||
ios2.fill('2');
|
||||
|
||||
ios1.move(ios2);
|
||||
|
||||
assert(ios1.rdstate() == std::ios::goodbit);
|
||||
assert(ios1.rdbuf() == 0);
|
||||
assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
|
||||
assert(ios1.precision() == 2);
|
||||
assert(ios1.width() == 12);
|
||||
assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
|
||||
assert(ios1.exceptions() == std::ios::eofbit);
|
||||
assert(!f1_called);
|
||||
assert(!f2_called);
|
||||
assert(!g1_called);
|
||||
assert(!g2_called);
|
||||
assert(!g3_called);
|
||||
assert(ios1.iword(0) == 4);
|
||||
assert(ios1.iword(1) == 5);
|
||||
assert(ios1.iword(2) == 6);
|
||||
assert(ios1.iword(3) == 7);
|
||||
assert(ios1.iword(4) == 8);
|
||||
assert(ios1.iword(5) == 9);
|
||||
assert(ios1.pword(0) == &d1);
|
||||
assert(ios1.pword(1) == &d2);
|
||||
assert(ios1.tie() == (std::ostream*)2);
|
||||
assert(ios1.fill() == '2');
|
||||
ios1.imbue(std::locale("C"));
|
||||
assert(!f1_called);
|
||||
assert(!f2_called);
|
||||
assert(g1_called);
|
||||
assert(g2_called);
|
||||
assert(g3_called);
|
||||
|
||||
assert(ios2.rdbuf() == &sb2);
|
||||
assert(ios2.tie() == 0);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// char narrow(char_type c, char dfault) const;
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::ios ios(0);
|
||||
assert(ios.narrow('c', '*') == 'c');
|
||||
assert(ios.narrow('\xFE', '*') == '*');
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// basic_streambuf<charT,traits>* rdbuf() const;
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
const std::ios ios(0);
|
||||
assert(ios.rdbuf() == 0);
|
||||
}
|
||||
{
|
||||
std::streambuf* sb = (std::streambuf*)1;
|
||||
const std::ios ios(sb);
|
||||
assert(ios.rdbuf() == sb);
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(ios.rdbuf() == 0);
|
||||
assert(!ios.good());
|
||||
std::streambuf* sb = (std::streambuf*)1;
|
||||
std::streambuf* sb2 = ios.rdbuf(sb);
|
||||
assert(sb2 == 0);
|
||||
assert(ios.rdbuf() == sb);
|
||||
assert(ios.good());
|
||||
sb2 = ios.rdbuf(0);
|
||||
assert(sb2 == (std::streambuf*)1);
|
||||
assert(ios.rdbuf() == 0);
|
||||
assert(ios.bad());
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// void set_rdbuf(basic_streambuf<charT, traits>* sb);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
};
|
||||
|
||||
struct testios
|
||||
: public std::ios
|
||||
{
|
||||
testios(std::streambuf* p) : std::ios(p) {}
|
||||
void set_rdbuf(std::streambuf* x) {std::ios::set_rdbuf(x);}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
testbuf sb1;
|
||||
testbuf sb2;
|
||||
testios ios(&sb1);
|
||||
try
|
||||
{
|
||||
ios.setstate(std::ios::badbit);
|
||||
ios.exceptions(std::ios::badbit);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
ios.set_rdbuf(&sb2);
|
||||
assert(ios.rdbuf() == &sb2);
|
||||
try
|
||||
{
|
||||
ios.setstate(std::ios::badbit);
|
||||
ios.exceptions(std::ios::badbit);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
ios.set_rdbuf(0);
|
||||
assert(ios.rdbuf() == 0);
|
||||
}
|
@@ -0,0 +1,168 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// REQUIRES: locale.en_US.UTF-8
|
||||
// REQUIRES: locale.fr_FR.UTF-8
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// void move(basic_ios&& rhs);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
struct testbuf
|
||||
: public std::streambuf
|
||||
{
|
||||
};
|
||||
|
||||
struct testios
|
||||
: public std::ios
|
||||
{
|
||||
testios(std::streambuf* p) : std::ios(p) {}
|
||||
void swap(std::ios& x) {std::ios::swap(x);}
|
||||
};
|
||||
|
||||
bool f1_called = false;
|
||||
bool f2_called = false;
|
||||
|
||||
bool g1_called = false;
|
||||
bool g2_called = false;
|
||||
bool g3_called = false;
|
||||
|
||||
void f1(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
assert(index == 4);
|
||||
f1_called = true;
|
||||
}
|
||||
|
||||
void f2(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
assert(index == 5);
|
||||
f2_called = true;
|
||||
}
|
||||
|
||||
void g1(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
assert(index == 7);
|
||||
g1_called = true;
|
||||
}
|
||||
|
||||
void g2(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
assert(index == 8);
|
||||
g2_called = true;
|
||||
}
|
||||
|
||||
void g3(std::ios_base::event ev, std::ios_base& stream, int index)
|
||||
{
|
||||
assert(index == 9);
|
||||
g3_called = true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
testbuf sb1;
|
||||
testios ios1(&sb1);
|
||||
ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
|
||||
ios1.precision(1);
|
||||
ios1.width(11);
|
||||
ios1.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
ios1.exceptions(std::ios::failbit);
|
||||
ios1.setstate(std::ios::eofbit);
|
||||
ios1.register_callback(f1, 4);
|
||||
ios1.register_callback(f2, 5);
|
||||
ios1.iword(0) = 1;
|
||||
ios1.iword(1) = 2;
|
||||
ios1.iword(2) = 3;
|
||||
char c1, c2, c3;
|
||||
ios1.pword(0) = &c1;
|
||||
ios1.pword(1) = &c2;
|
||||
ios1.pword(2) = &c3;
|
||||
ios1.tie((std::ostream*)1);
|
||||
ios1.fill('1');
|
||||
|
||||
testbuf sb2;
|
||||
testios ios2(&sb2);
|
||||
ios2.flags(std::ios::showpoint | std::ios::uppercase);
|
||||
ios2.precision(2);
|
||||
ios2.width(12);
|
||||
ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
|
||||
ios2.exceptions(std::ios::eofbit);
|
||||
ios2.setstate(std::ios::goodbit);
|
||||
ios2.register_callback(g1, 7);
|
||||
ios2.register_callback(g2, 8);
|
||||
ios2.register_callback(g3, 9);
|
||||
ios2.iword(0) = 4;
|
||||
ios2.iword(1) = 5;
|
||||
ios2.iword(2) = 6;
|
||||
ios2.iword(3) = 7;
|
||||
ios2.iword(4) = 8;
|
||||
ios2.iword(5) = 9;
|
||||
char d1, d2;
|
||||
ios2.pword(0) = &d1;
|
||||
ios2.pword(1) = &d2;
|
||||
ios2.tie((std::ostream*)2);
|
||||
ios2.fill('2');
|
||||
|
||||
ios1.swap(ios2);
|
||||
|
||||
assert(ios1.rdstate() == std::ios::goodbit);
|
||||
assert(ios1.rdbuf() == &sb1);
|
||||
assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
|
||||
assert(ios1.precision() == 2);
|
||||
assert(ios1.width() == 12);
|
||||
assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
|
||||
assert(ios1.exceptions() == std::ios::eofbit);
|
||||
assert(!f1_called);
|
||||
assert(!f2_called);
|
||||
assert(!g1_called);
|
||||
assert(!g2_called);
|
||||
assert(!g3_called);
|
||||
assert(ios1.iword(0) == 4);
|
||||
assert(ios1.iword(1) == 5);
|
||||
assert(ios1.iword(2) == 6);
|
||||
assert(ios1.iword(3) == 7);
|
||||
assert(ios1.iword(4) == 8);
|
||||
assert(ios1.iword(5) == 9);
|
||||
assert(ios1.pword(0) == &d1);
|
||||
assert(ios1.pword(1) == &d2);
|
||||
assert(ios1.tie() == (std::ostream*)2);
|
||||
assert(ios1.fill() == '2');
|
||||
ios1.imbue(std::locale("C"));
|
||||
assert(!f1_called);
|
||||
assert(!f2_called);
|
||||
assert(g1_called);
|
||||
assert(g2_called);
|
||||
assert(g3_called);
|
||||
|
||||
assert(ios2.rdstate() == std::ios::eofbit);
|
||||
assert(ios2.rdbuf() == &sb2);
|
||||
assert(ios2.flags() == (std::ios::boolalpha | std::ios::dec | std::ios::fixed));
|
||||
assert(ios2.precision() == 1);
|
||||
assert(ios2.width() == 11);
|
||||
assert(ios2.getloc().name() == LOCALE_en_US_UTF_8);
|
||||
assert(ios2.exceptions() == std::ios::failbit);
|
||||
assert(ios2.iword(0) == 1);
|
||||
assert(ios2.iword(1) == 2);
|
||||
assert(ios2.iword(2) == 3);
|
||||
assert(ios2.pword(0) == &c1);
|
||||
assert(ios2.pword(1) == &c2);
|
||||
assert(ios2.pword(2) == &c3);
|
||||
assert(ios2.tie() == (std::ostream*)1);
|
||||
assert(ios2.fill() == '1');
|
||||
ios2.imbue(std::locale("C"));
|
||||
assert(f1_called);
|
||||
assert(f2_called);
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// basic_ostream<charT,traits>* tie() const;
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::basic_ios<char> ios(0);
|
||||
assert(ios.tie() == 0);
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ios ios(0);
|
||||
std::ostream* os = (std::ostream*)1;
|
||||
std::ostream* r = ios.tie(os);
|
||||
assert(r == 0);
|
||||
assert(ios.tie() == os);
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// char_type widen(char c) const;
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::ios ios(0);
|
||||
assert(ios.widen('c') == 'c');
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// bool bad() const;
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(ios.bad());
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(ios.bad());
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
assert(!ios.bad());
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(!ios.bad());
|
||||
ios.setstate(std::ios::failbit);
|
||||
assert(!ios.bad());
|
||||
ios.setstate(std::ios::badbit);
|
||||
assert(ios.bad());
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// operator unspecified-bool-type() const;
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(static_cast<bool>(ios) == !ios.fail());
|
||||
ios.setstate(std::ios::failbit);
|
||||
assert(static_cast<bool>(ios) == !ios.fail());
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// void clear(iostate state = goodbit);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
ios.clear();
|
||||
assert(ios.rdstate() == std::ios::badbit);
|
||||
try
|
||||
{
|
||||
ios.exceptions(std::ios::badbit);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
ios.clear();
|
||||
assert(false);
|
||||
}
|
||||
catch (std::ios::failure&)
|
||||
{
|
||||
assert(ios.rdstate() == std::ios::badbit);
|
||||
}
|
||||
try
|
||||
{
|
||||
ios.clear(std::ios::eofbit);
|
||||
assert(false);
|
||||
}
|
||||
catch (std::ios::failure&)
|
||||
{
|
||||
assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
|
||||
}
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
ios.clear();
|
||||
assert(ios.rdstate() == std::ios::goodbit);
|
||||
ios.exceptions(std::ios::badbit);
|
||||
ios.clear();
|
||||
assert(ios.rdstate() == std::ios::goodbit);
|
||||
ios.clear(std::ios::eofbit);
|
||||
assert(ios.rdstate() == std::ios::eofbit);
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// bool eof() const;
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(!ios.eof());
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(ios.eof());
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
assert(!ios.eof());
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(ios.eof());
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// iostate exceptions() const;
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
const std::ios ios(0);
|
||||
assert(ios.exceptions() == std::ios::goodbit);
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
const std::ios ios(&sb);
|
||||
assert(ios.exceptions() == std::ios::goodbit);
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// iostate exceptions() const;
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(ios.exceptions() == std::ios::goodbit);
|
||||
ios.exceptions(std::ios::eofbit);
|
||||
assert(ios.exceptions() == std::ios::eofbit);
|
||||
try
|
||||
{
|
||||
ios.exceptions(std::ios::badbit);
|
||||
assert(false);
|
||||
}
|
||||
catch (std::ios::failure&)
|
||||
{
|
||||
}
|
||||
assert(ios.exceptions() == std::ios::badbit);
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
assert(ios.exceptions() == std::ios::goodbit);
|
||||
ios.exceptions(std::ios::eofbit);
|
||||
assert(ios.exceptions() == std::ios::eofbit);
|
||||
ios.exceptions(std::ios::badbit);
|
||||
assert(ios.exceptions() == std::ios::badbit);
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// bool fail() const;
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(ios.fail());
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(ios.fail());
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
assert(!ios.fail());
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(!ios.fail());
|
||||
ios.setstate(std::ios::badbit);
|
||||
assert(ios.fail());
|
||||
ios.setstate(std::ios::failbit);
|
||||
assert(ios.fail());
|
||||
}
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// bool good() const;
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(!ios.good());
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
assert(ios.good());
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(!ios.good());
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// bool operator!() const;
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(!ios == ios.fail());
|
||||
ios.setstate(std::ios::failbit);
|
||||
assert(!ios == ios.fail());
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// iostate rdstate() const;
|
||||
|
||||
#include <ios>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(ios.rdstate() == std::ios::badbit);
|
||||
ios.setstate(std::ios::failbit);
|
||||
assert(ios.rdstate() == (std::ios::failbit | std::ios::badbit));
|
||||
}
|
@@ -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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits> class basic_ios
|
||||
|
||||
// void setstate(iostate state);
|
||||
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
#include <cassert>
|
||||
|
||||
struct testbuf : public std::streambuf {};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::ios ios(0);
|
||||
ios.setstate(std::ios::goodbit);
|
||||
assert(ios.rdstate() == std::ios::badbit);
|
||||
try
|
||||
{
|
||||
ios.exceptions(std::ios::badbit);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
ios.setstate(std::ios::goodbit);
|
||||
assert(false);
|
||||
}
|
||||
catch (std::ios::failure&)
|
||||
{
|
||||
assert(ios.rdstate() == std::ios::badbit);
|
||||
}
|
||||
try
|
||||
{
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(false);
|
||||
}
|
||||
catch (std::ios::failure&)
|
||||
{
|
||||
assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
|
||||
}
|
||||
}
|
||||
{
|
||||
testbuf sb;
|
||||
std::ios ios(&sb);
|
||||
ios.setstate(std::ios::goodbit);
|
||||
assert(ios.rdstate() == std::ios::goodbit);
|
||||
ios.setstate(std::ios::eofbit);
|
||||
assert(ios.rdstate() == std::ios::eofbit);
|
||||
ios.setstate(std::ios::failbit);
|
||||
assert(ios.rdstate() == (std::ios::eofbit | std::ios::failbit));
|
||||
}
|
||||
}
|
33
test/std/input.output/iostreams.base/ios/types.pass.cpp
Normal file
33
test/std/input.output/iostreams.base/ios/types.pass.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <ios>
|
||||
|
||||
// template <class charT, class traits = char_traits<charT> >
|
||||
// class basic_ios : public ios_base
|
||||
// {
|
||||
// public:
|
||||
// typedef charT char_type;
|
||||
// typedef typename traits::int_type int_type;
|
||||
// typedef typename traits::pos_type pos_type;
|
||||
// typedef typename traits::off_type off_type;
|
||||
// typedef traits traits_type;
|
||||
|
||||
#include <ios>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::ios_base, std::basic_ios<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ios<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_ios<char>::traits_type, std::char_traits<char> >::value), "");
|
||||
static_assert((std::is_same<std::basic_ios<char>::int_type, std::char_traits<char>::int_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ios<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_ios<char>::off_type, std::char_traits<char>::off_type>::value), "");
|
||||
}
|
Reference in New Issue
Block a user