#include <locale>
#include <sstream>
#include <ostream>
#include <testsuite_hooks.h>
class numpunct_checked : public std::numpunct<char>
{
typedef std::numpunct<char> 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() + "st"; }
};
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
const string empty;
const string basestr("true");
const string derivedstr("truest");
const locale loc(locale::classic(), new numpunct_checked);
stringbuf sbuf;
ostream os(&sbuf);
os.setf(ios_base::boolalpha);
const numpunct<char>& np = use_facet<numpunct<char> >(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;
}