#include <locale>
#include <sstream>
#include <ostream>
#include <testsuite_hooks.h>
class numpunct_checked : public std::numpunct<wchar_t>
{
typedef std::numpunct<wchar_t> base;
public:
explicit
numpunct_checked(std::size_t refs = 0): base(refs) { }
string_type
base_truename() const
{ return base::do_truename(); }
protected:
virtual string_type
do_truename() const
{ return base::do_truename() + L"st"; }
};
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
const wstring empty;
const wstring basestr(L"true");
const wstring derivedstr(L"truest");
const locale loc(locale::classic(), new numpunct_checked);
wstringbuf sbuf;
wostream os(&sbuf);
os.setf(ios_base::boolalpha);
const numpunct<wchar_t>& np = use_facet<numpunct<wchar_t> >(loc);
VERIFY( np.truename() == derivedstr );
os.imbue(loc);
os << true;
VERIFY( sbuf.str() == derivedstr );
sbuf.str(empty);
os.imbue(locale::classic());
os << true;
VERIFY( sbuf.str() == basestr );
sbuf.str(empty);
os.imbue(loc);
os << true;
VERIFY( sbuf.str() == derivedstr );
VERIFY( np.truename() == derivedstr );
const numpunct_checked& npd = static_cast<const numpunct_checked&>(np);
VERIFY( npd.base_truename() == basestr );
}
int main()
{
test01();
return 0;
}