#include <locale>
#include <sstream>
#include <ostream>
#include <stdexcept>
#include <ext/pod_char_traits.h>
#include <testsuite_hooks.h>
void test01()
{
using namespace std;
using __gnu_test::pod_type;
typedef numpunct<pod_type>::string_type string_type;
typedef basic_ostringstream<pod_type> ostream_type;
bool test = true;
ostream_type os;
const locale loc = locale::classic();
os.imbue(loc);
os.setf(ios_base::boolalpha);
os.exceptions(ios_base::badbit);
try
{
os << true;
test = false;
}
catch(const bad_cast& obj)
{ }
catch(...)
{ test = false; }
VERIFY( test );
const locale loc2(loc, new num_put<pod_type>);
os.clear();
os.imbue(loc2);
try
{
os << true;
test = false;
}
catch(const bad_cast& obj)
{ }
catch(...)
{ test = false; }
VERIFY( test );
const locale loc3(loc2, new ctype<pod_type>);
os.clear();
os.imbue(loc3);
try
{
os << true;
test = false;
}
catch(const bad_cast& obj)
{ }
catch(...)
{ test = false; }
VERIFY( test );
const locale loc4(loc3, new numpunct<pod_type>);
os.clear();
os.imbue(loc4);
try
{
os << long(500);
string_type s = os.str();
VERIFY( s.length() == 3 );
VERIFY( os.narrow(s[0], char()) == '5' );
VERIFY( os.narrow(s[1], char()) == '0' );
VERIFY( os.narrow(s[2], char()) == '0' );
}
catch(const bad_cast& obj)
{ test = false; }
catch(...)
{ test = false; }
VERIFY( test );
}
int main()
{
test01();
return 0;
}