Skip to content

Commit

Permalink
Protect std::ios tests under libcpp-no-exceptions
Browse files Browse the repository at this point in the history
Skip tests that expect an exception be thrown. Also add
some missing asserts in the original test.

Differential Revision: https://reviews.llvm.org/D26512

llvm-svn: 286823
  • Loading branch information
Roger Ferrer Ibanez committed Nov 14, 2016
1 parent c78f5d4 commit aa35ecf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Expand Up @@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: libcpp-no-exceptions
// REQUIRES: locale.en_US.UTF-8
// REQUIRES: locale.fr_FR.UTF-8

Expand All @@ -23,6 +22,8 @@

#include "platform_support.h" // locale name macros

#include "test_macros.h"

struct testbuf
: public std::streambuf
{
Expand Down Expand Up @@ -158,6 +159,7 @@ int main()
ios1.copyfmt(ios1);
assert(!f1_called);

#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
ios1.copyfmt(ios2);
Expand All @@ -166,6 +168,9 @@ int main()
catch (std::ios_base::failure&)
{
}
#else
ios1.copyfmt(ios2);
#endif
assert(ios1.rdstate() == std::ios::eofbit);
assert(ios1.rdbuf() == &sb1);
assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
Expand Down
Expand Up @@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: libcpp-no-exceptions
// <ios>

// template <class charT, class traits> class basic_ios
Expand All @@ -18,6 +17,8 @@
#include <streambuf>
#include <cassert>

#include "test_macros.h"

struct testbuf
: public std::streambuf
{
Expand All @@ -35,16 +36,20 @@ int main()
testbuf sb1;
testbuf sb2;
testios ios(&sb1);
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
ios.setstate(std::ios::badbit);
ios.exceptions(std::ios::badbit);
assert(false);
}
catch (...)
{
}
#endif
ios.set_rdbuf(&sb2);
assert(ios.rdbuf() == &sb2);
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
ios.setstate(std::ios::badbit);
Expand All @@ -53,6 +58,7 @@ int main()
catch (...)
{
}
#endif
ios.set_rdbuf(0);
assert(ios.rdbuf() == 0);
}
Expand Up @@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: libcpp-no-exceptions
// <ios>

// template <class charT, class traits> class basic_ios
Expand All @@ -18,6 +17,8 @@
#include <streambuf>
#include <cassert>

#include "test_macros.h"

struct testbuf : public std::streambuf {};

int main()
Expand All @@ -26,9 +27,11 @@ int main()
std::ios ios(0);
ios.clear();
assert(ios.rdstate() == std::ios::badbit);
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
ios.exceptions(std::ios::badbit);
assert(false);
}
catch (...)
{
Expand All @@ -51,6 +54,7 @@ int main()
{
assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
}
#endif
}
{
testbuf sb;
Expand Down
Expand Up @@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: libcpp-no-exceptions
// <ios>

// template <class charT, class traits> class basic_ios
Expand All @@ -18,6 +17,8 @@
#include <streambuf>
#include <cassert>

#include "test_macros.h"

struct testbuf : public std::streambuf {};

int main()
Expand All @@ -27,6 +28,7 @@ int main()
assert(ios.exceptions() == std::ios::goodbit);
ios.exceptions(std::ios::eofbit);
assert(ios.exceptions() == std::ios::eofbit);
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
ios.exceptions(std::ios::badbit);
Expand All @@ -36,6 +38,7 @@ int main()
{
}
assert(ios.exceptions() == std::ios::badbit);
#endif
}
{
testbuf sb;
Expand Down
Expand Up @@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: libcpp-no-exceptions
// <ios>

// template <class charT, class traits> class basic_ios
Expand All @@ -18,6 +17,8 @@
#include <streambuf>
#include <cassert>

#include "test_macros.h"

struct testbuf : public std::streambuf {};

int main()
Expand All @@ -26,9 +27,11 @@ int main()
std::ios ios(0);
ios.setstate(std::ios::goodbit);
assert(ios.rdstate() == std::ios::badbit);
#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
ios.exceptions(std::ios::badbit);
assert(false);
}
catch (...)
{
Expand All @@ -51,6 +54,7 @@ int main()
{
assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
}
#endif
}
{
testbuf sb;
Expand Down

0 comments on commit aa35ecf

Please sign in to comment.