aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/22_locale/numpunct/members
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/22_locale/numpunct/members')
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/char/1.cc6
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/char/2.cc6
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_1.cc78
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_2.cc90
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_env.cc2
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_locale.cc2
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/1.cc6
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/2.cc6
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_1.cc78
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_2.cc90
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_env.cc2
-rw-r--r--libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_locale.cc2
12 files changed, 352 insertions, 16 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/1.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/1.cc
index 023c64f8d7c..b57ecb21fac 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/1.cc
@@ -31,9 +31,9 @@ void test01()
// basic construction
locale loc_c = locale::classic();
- locale loc_us = __gnu_cxx_test::try_named_locale("en_US");
- locale loc_fr = __gnu_cxx_test::try_named_locale("fr_FR");
- locale loc_de = __gnu_cxx_test::try_named_locale("de_DE");
+ locale loc_us = __gnu_test::try_named_locale("en_US");
+ locale loc_fr = __gnu_test::try_named_locale("fr_FR");
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_us != loc_fr );
VERIFY( loc_us != loc_de );
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/2.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/2.cc
index b6c8b2ddecc..0ff21db6dce 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/2.cc
@@ -31,9 +31,9 @@ void test02()
// basic construction
locale loc_c = locale::classic();
- locale loc_us = __gnu_cxx_test::try_named_locale("en_US");
- locale loc_fr = __gnu_cxx_test::try_named_locale("fr_FR");
- locale loc_de = __gnu_cxx_test::try_named_locale("de_DE");
+ locale loc_us = __gnu_test::try_named_locale("en_US");
+ locale loc_fr = __gnu_test::try_named_locale("fr_FR");
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_us != loc_fr );
VERIFY( loc_us != loc_de );
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_1.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_1.cc
new file mode 100644
index 00000000000..002b0c47e37
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_1.cc
@@ -0,0 +1,78 @@
+// 2003-07-06 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#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"; }
+};
+
+// Thwart locale caching strategies that incorrectly overwrite base
+// class data.
+void test01()
+{
+ using namespace std;
+
+ bool test = true;
+ 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);
+
+ // Pre-cache sanity check.
+ const numpunct<char>& np = use_facet<numpunct<char> >(loc);
+ VERIFY( np.truename() == derivedstr );
+
+ // Cache.
+ os.imbue(loc);
+ os << true;
+ VERIFY( sbuf.str() == derivedstr );
+
+ // Post-cache sanity check, make sure that base class is still fine.
+ VERIFY( np.truename() == derivedstr );
+ const numpunct_checked& npd = static_cast<const numpunct_checked&>(np);
+ VERIFY( npd.base_truename() == basestr );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_2.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_2.cc
new file mode 100644
index 00000000000..729e82a64bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/cache_2.cc
@@ -0,0 +1,90 @@
+// 2003-07-06 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#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"; }
+};
+
+// Changing caches deletes old cache, adds new one.
+void test01()
+{
+ using namespace std;
+
+ bool test = 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);
+
+ // Pre-cache sanity check.
+ const numpunct<char>& np = use_facet<numpunct<char> >(loc);
+ VERIFY( np.truename() == derivedstr );
+
+ // Cache.
+ os.imbue(loc);
+ os << true;
+ VERIFY( sbuf.str() == derivedstr );
+
+ // Re-cache.
+ sbuf.str(empty);
+ os.imbue(locale::classic());
+ os << true;
+ VERIFY( sbuf.str() == basestr );
+
+ // Cache new locale again.
+ sbuf.str(empty);
+ os.imbue(loc);
+ os << true;
+ VERIFY( sbuf.str() == derivedstr );
+
+ // Post-cache sanity check, make sure that base class is still fine.
+ VERIFY( np.truename() == derivedstr );
+ const numpunct_checked& npd = static_cast<const numpunct_checked&>(np);
+ VERIFY( npd.base_truename() == basestr );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_env.cc
index 4f1d5e3f6a9..19e4210ff2c 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_env.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_env.cc
@@ -32,7 +32,7 @@
int main()
{
- using namespace __gnu_cxx_test;
+ using namespace __gnu_test;
func_callback two;
two.push_back(&test01);
two.push_back(&test02);
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_locale.cc
index 8d7871815db..292b8c738e4 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_locale.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/wrapped_locale.cc
@@ -32,7 +32,7 @@
int main()
{
- using namespace __gnu_cxx_test;
+ using namespace __gnu_test;
func_callback two;
two.push_back(&test01);
two.push_back(&test02);
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/1.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/1.cc
index e3426fda43c..ef1c9f0af7d 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/1.cc
@@ -31,9 +31,9 @@ void test01()
// basic construction
locale loc_c = locale::classic();
- locale loc_us = __gnu_cxx_test::try_named_locale("en_US");
- locale loc_fr = __gnu_cxx_test::try_named_locale("fr_FR");
- locale loc_de = __gnu_cxx_test::try_named_locale("de_DE");
+ locale loc_us = __gnu_test::try_named_locale("en_US");
+ locale loc_fr = __gnu_test::try_named_locale("fr_FR");
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_us != loc_fr );
VERIFY( loc_us != loc_de );
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/2.cc
index 9b55ae95e33..fce8fa2c6d7 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/2.cc
@@ -31,9 +31,9 @@ void test02()
// basic construction
locale loc_c = locale::classic();
- locale loc_us = __gnu_cxx_test::try_named_locale("en_US");
- locale loc_fr = __gnu_cxx_test::try_named_locale("fr_FR");
- locale loc_de = __gnu_cxx_test::try_named_locale("de_DE");
+ locale loc_us = __gnu_test::try_named_locale("en_US");
+ locale loc_fr = __gnu_test::try_named_locale("fr_FR");
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
VERIFY( loc_c != loc_de );
VERIFY( loc_us != loc_fr );
VERIFY( loc_us != loc_de );
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_1.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_1.cc
new file mode 100644
index 00000000000..0b41e963f50
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_1.cc
@@ -0,0 +1,78 @@
+// 2003-07-06 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#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"; }
+};
+
+// Thwart locale caching strategies that incorrectly overwrite base
+// class data.
+void test01()
+{
+ using namespace std;
+
+ bool test = true;
+ 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);
+
+ // Pre-cache sanity check.
+ const numpunct<wchar_t>& np = use_facet<numpunct<wchar_t> >(loc);
+ VERIFY( np.truename() == derivedstr );
+
+ // Cache.
+ os.imbue(loc);
+ os << true;
+ VERIFY( sbuf.str() == derivedstr );
+
+ // Post-cache sanity check, make sure that base class is still fine.
+ VERIFY( np.truename() == derivedstr );
+ const numpunct_checked& npd = static_cast<const numpunct_checked&>(np);
+ VERIFY( npd.base_truename() == basestr );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_2.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_2.cc
new file mode 100644
index 00000000000..9a3c4872e5c
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/cache_2.cc
@@ -0,0 +1,90 @@
+// 2003-07-06 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#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"; }
+};
+
+// Changing caches deletes old cache, adds new one.
+void test01()
+{
+ using namespace std;
+
+ bool test = 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);
+
+ // Pre-cache sanity check.
+ const numpunct<wchar_t>& np = use_facet<numpunct<wchar_t> >(loc);
+ VERIFY( np.truename() == derivedstr );
+
+ // Cache.
+ os.imbue(loc);
+ os << true;
+ VERIFY( sbuf.str() == derivedstr );
+
+ // Re-cache.
+ sbuf.str(empty);
+ os.imbue(locale::classic());
+ os << true;
+ VERIFY( sbuf.str() == basestr );
+
+ // Cache new locale again.
+ sbuf.str(empty);
+ os.imbue(loc);
+ os << true;
+ VERIFY( sbuf.str() == derivedstr );
+
+ // Post-cache sanity check, make sure that base class is still fine.
+ VERIFY( np.truename() == derivedstr );
+ const numpunct_checked& npd = static_cast<const numpunct_checked&>(np);
+ VERIFY( npd.base_truename() == basestr );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_env.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_env.cc
index 4f1d5e3f6a9..19e4210ff2c 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_env.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_env.cc
@@ -32,7 +32,7 @@
int main()
{
- using namespace __gnu_cxx_test;
+ using namespace __gnu_test;
func_callback two;
two.push_back(&test01);
two.push_back(&test02);
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_locale.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_locale.cc
index 8d7871815db..292b8c738e4 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_locale.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/members/wchar_t/wrapped_locale.cc
@@ -32,7 +32,7 @@
int main()
{
- using namespace __gnu_cxx_test;
+ using namespace __gnu_test;
func_callback two;
two.push_back(&test01);
two.push_back(&test02);