aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@purist.soma.redhat.com>2000-09-12 18:50:16 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2000-09-12 18:50:16 +0000
commit3e80ddc74200fb7c9c3a0e18321051dd9fd6c9ca (patch)
treedb46101dab3721623749f05f0af93e4d0c39fb07
parenta0b6cdee336967a6723b43438f567def4e86730e (diff)
downloadgcc-3e80ddc74200fb7c9c3a0e18321051dd9fd6c9ca.zip
gcc-3e80ddc74200fb7c9c3a0e18321051dd9fd6c9ca.tar.gz
gcc-3e80ddc74200fb7c9c3a0e18321051dd9fd6c9ca.tar.bz2
global_templates.cc (test01): Add negative tests for use_facet.
2000-09-12 Benjamin Kosnik <bkoz@purist.soma.redhat.com> * testsuite/22_locale/global_templates.cc (test01): Add negative tests for use_facet. * bits/localefwd.h (locale::operator()): Minor tweaks. * bits/locale_facets.tcc (locale::operator()): Same. * testsuite/22_locale/operators.cc: New file. * testsuite/22_locale/facet.cc (output_iterator): Remove gnu_input_iterator, gnu_output_iterator. From-SVN: r36372
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/bits/locale_facets.tcc4
-rw-r--r--libstdc++-v3/bits/localefwd.h4
-rw-r--r--libstdc++-v3/testsuite/22_locale/facet.cc73
-rw-r--r--libstdc++-v3/testsuite/22_locale/global_templates.cc19
-rw-r--r--libstdc++-v3/testsuite/22_locale/operators.cc53
6 files changed, 101 insertions, 64 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index db39128..77283e1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+2000-09-12 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
+
+ * testsuite/22_locale/global_templates.cc (test01): Add negative
+ tests for use_facet.
+
+ * bits/localefwd.h (locale::operator()): Minor tweaks.
+ * bits/locale_facets.tcc (locale::operator()): Same.
+ * testsuite/22_locale/operators.cc: New file.
+
+ * testsuite/22_locale/facet.cc (output_iterator): Remove
+ gnu_input_iterator, gnu_output_iterator.
+
2000-09-11 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* acinclude.m4 (GLIBCPP_CHECK_GNU_MAKE): Remove test != "0".
diff --git a/libstdc++-v3/bits/locale_facets.tcc b/libstdc++-v3/bits/locale_facets.tcc
index 199aa16..594e604 100644
--- a/libstdc++-v3/bits/locale_facets.tcc
+++ b/libstdc++-v3/bits/locale_facets.tcc
@@ -54,8 +54,8 @@ namespace std
template<typename _CharT, typename _Traits, typename _Alloc>
bool
- locale::operator()(const basic_string<_CharT,_Traits,_Alloc>& __s1,
- const basic_string<_CharT,_Traits,_Alloc>& __s2) const
+ locale::operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
+ const basic_string<_CharT, _Traits, _Alloc>& __s2) const
{
// XXX should not need to qualify here.
// typedef collate<_CharT> __collate_type;
diff --git a/libstdc++-v3/bits/localefwd.h b/libstdc++-v3/bits/localefwd.h
index a23369b..f30dd40 100644
--- a/libstdc++-v3/bits/localefwd.h
+++ b/libstdc++-v3/bits/localefwd.h
@@ -280,8 +280,8 @@ namespace std
template<typename _Char, typename _Traits, typename _Alloc>
bool
- operator()(const basic_string<_Char,_Traits,_Alloc>& __s1,
- const basic_string<_Char,_Traits,_Alloc>& __s2) const;
+ operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
+ const basic_string<_Char, _Traits, _Alloc>& __s2) const;
// Global locale objects:
static locale
diff --git a/libstdc++-v3/testsuite/22_locale/facet.cc b/libstdc++-v3/testsuite/22_locale/facet.cc
index 1930c50..cea5fbe 100644
--- a/libstdc++-v3/testsuite/22_locale/facet.cc
+++ b/libstdc++-v3/testsuite/22_locale/facet.cc
@@ -25,49 +25,8 @@
#include <debug_assert.h>
// 1 a class if a facet if it is publicly derived from another facet
-class gnu_input_iterator: public std::iterator<std::input_iterator_tag, char>
-{
- value_type it;
-public:
- gnu_input_iterator(value_type orig): it(orig) { }
-
- value_type
- operator*() const { return it; }
-
- reference
- operator++(){ return ++it; }
-
- reference
- operator++(int){ ++it; return it; }
-};
-
-bool
-operator==(const gnu_input_iterator& lhs, const gnu_input_iterator& rhs)
-{ return true; }
-
-bool
-operator!=(const gnu_input_iterator& lhs, const gnu_input_iterator& rhs)
-{ return true; }
-
-class gnu_output_iterator: public std::iterator<std::output_iterator_tag, char>
-{
- value_type it;
-public:
- gnu_output_iterator(value_type orig): it(orig) { }
-
- value_type
- operator*(){ return it; }
-
- gnu_output_iterator&
- operator=(value_type obj){ it = obj; return *this; }
-
- reference
- operator++(){ return ++it; }
-
- reference
- operator++(int){ ++it; return it; }
-
-};
+typedef std::istreambuf_iterator<char> input_iterator;
+typedef std::ostreambuf_iterator<char> output_iterator;
class gnu_collate: public std::collate<char> { };
class gnu_ctype: public std::ctype<char> { };
@@ -116,20 +75,20 @@ public:
};
-class gnu_money_get_in: public std::money_get<char, gnu_input_iterator>
+class gnu_money_get_in: public std::money_get<char, input_iterator>
{
public:
explicit
gnu_money_get_in(size_t refs = 0)
- : std::money_get<char, gnu_input_iterator>(refs) { }
+ : std::money_get<char, input_iterator>(refs) { }
};
-class gnu_money_put_out: public std::money_put<char, gnu_output_iterator>
+class gnu_money_put_out: public std::money_put<char, output_iterator>
{
public:
explicit
gnu_money_put_out(size_t refs = 0)
- : std::money_put<char, gnu_output_iterator>(refs) { }
+ : std::money_put<char, output_iterator>(refs) { }
};
class gnu_numpunct_byname: public std::numpunct_byname<char>
@@ -140,20 +99,20 @@ public:
: std::numpunct_byname<char>(c, refs) { }
};
-class gnu_num_get_in: public std::num_get<char, gnu_input_iterator>
+class gnu_num_get_in: public std::num_get<char, input_iterator>
{
public:
explicit
gnu_num_get_in(size_t refs = 0)
- : std::num_get<char, gnu_input_iterator>(refs) { }
+ : std::num_get<char, input_iterator>(refs) { }
};
-class gnu_num_put_out: public std::num_put<char, gnu_output_iterator>
+class gnu_num_put_out: public std::num_put<char, output_iterator>
{
public:
explicit
gnu_num_put_out(size_t refs = 0)
- : std::num_put<char, gnu_output_iterator>(refs) { }
+ : std::num_put<char, output_iterator>(refs) { }
};
class gnu_time_get_byname: public std::time_get_byname<char>
@@ -164,12 +123,12 @@ public:
: std::time_get_byname<char>(c, refs) { }
};
-class gnu_time_get_in: public std::time_get<char, gnu_input_iterator>
+class gnu_time_get_in: public std::time_get<char, input_iterator>
{
public:
explicit
gnu_time_get_in(size_t refs = 0)
- : std::time_get<char, gnu_input_iterator>(refs) { }
+ : std::time_get<char, input_iterator>(refs) { }
};
class gnu_time_put_byname: public std::time_put_byname<char>
@@ -180,12 +139,12 @@ public:
: std::time_put_byname<char>(c, refs) { }
};
-class gnu_time_put_out: public std::time_put<char, gnu_output_iterator>
+class gnu_time_put_out: public std::time_put<char, output_iterator>
{
public:
explicit
gnu_time_put_out(size_t refs = 0)
- : std::time_put<char, gnu_output_iterator>(refs) { }
+ : std::time_put<char, output_iterator>(refs) { }
};
class gnu_messages_byname: public std::messages_byname<char>
@@ -227,8 +186,8 @@ void test01()
gnu_time_put_byname obj15("gnu_message_byname", 0);
gnu_time_get_in obj16(0);
gnu_time_get_byname obj17("gnu_message_byname", 0);
- // gnu_num_put_out obj18(0);
- // gnu_num_get_in obj19(0);
+ gnu_num_put_out obj18(0);
+ gnu_num_get_in obj19(0);
gnu_numpunct_byname obj20("gnu_message_byname", 0);
gnu_money_put_out obj21(0);
gnu_money_get_in obj22(0);
diff --git a/libstdc++-v3/testsuite/22_locale/global_templates.cc b/libstdc++-v3/testsuite/22_locale/global_templates.cc
index 274b827..c207ccd 100644
--- a/libstdc++-v3/testsuite/22_locale/global_templates.cc
+++ b/libstdc++-v3/testsuite/22_locale/global_templates.cc
@@ -43,9 +43,22 @@ void test01()
// sanity check the constructed locale has the specialized facet.
VERIFY( has_facet<gnu_codecvt>(loc) );
- const ccodecvt& cvt01 = use_facet<ccodecvt>(cloc);
- const gnu_codecvt& cvt02 = use_facet<gnu_codecvt>(loc);
- // VERIFY( cvt01.id != cvt02.id ); // XXX no way to do this, really :(
+ try
+ { const ccodecvt& cvt01 = use_facet<ccodecvt>(cloc); }
+ catch(...)
+ { VERIFY( false ); }
+
+ try
+ { const gnu_codecvt& cvt02 = use_facet<gnu_codecvt>(loc); }
+ catch(...)
+ { VERIFY( false ); }
+
+ try
+ { const ccodecvt& cvt03 = use_facet<gnu_codecvt>(cloc); }
+ catch(bad_cast& obj)
+ { VERIFY( true ); }
+ catch(...)
+ { VERIFY( false ); }
}
int main ()
diff --git a/libstdc++-v3/testsuite/22_locale/operators.cc b/libstdc++-v3/testsuite/22_locale/operators.cc
new file mode 100644
index 0000000..e188d2d
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/operators.cc
@@ -0,0 +1,53 @@
+// 2000-09-11 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2000 Free Software Foundation
+//
+// 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.
+
+// 22.1.1.4 locale operators [lib.locale.operators]
+
+#include <locale>
+#include <debug_assert.h>
+
+typedef std::codecvt<char, char, mbstate_t> ccodecvt;
+class gnu_codecvt: public ccodecvt { };
+
+void test01()
+{
+ using namespace std;
+
+ bool test = true;
+ string str1, str2;
+
+ // construct a locale object with the C facet
+ const locale& cloc = locale::classic();
+ // construct a locale object with the specialized facet.
+ locale loc(locale::classic(), new gnu_codecvt);
+ VERIFY ( cloc != loc );
+ VERIFY ( !(cloc == loc) );
+
+ str1 = cloc.name();
+ str2 = loc.name();
+ VERIFY( loc(str1, str2) == false );
+}
+
+int main ()
+{
+ test01();
+
+ return 0;
+}