From: Benjamin Kosnik Date: Tue, 12 Sep 2000 18:50:16 +0000 (+0000) Subject: global_templates.cc (test01): Add negative tests for use_facet. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e80ddc74200fb7c9c3a0e18321051dd9fd6c9ca;p=platform%2Fupstream%2Fgcc.git global_templates.cc (test01): Add negative tests for use_facet. 2000-09-12 Benjamin Kosnik * 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 --- 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 + + * 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 * 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 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 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 // 1 a class if a facet if it is publicly derived from another facet -class gnu_input_iterator: public std::iterator -{ - 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 -{ - 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 input_iterator; +typedef std::ostreambuf_iterator output_iterator; class gnu_collate: public std::collate { }; class gnu_ctype: public std::ctype { }; @@ -116,20 +75,20 @@ public: }; -class gnu_money_get_in: public std::money_get +class gnu_money_get_in: public std::money_get { public: explicit gnu_money_get_in(size_t refs = 0) - : std::money_get(refs) { } + : std::money_get(refs) { } }; -class gnu_money_put_out: public std::money_put +class gnu_money_put_out: public std::money_put { public: explicit gnu_money_put_out(size_t refs = 0) - : std::money_put(refs) { } + : std::money_put(refs) { } }; class gnu_numpunct_byname: public std::numpunct_byname @@ -140,20 +99,20 @@ public: : std::numpunct_byname(c, refs) { } }; -class gnu_num_get_in: public std::num_get +class gnu_num_get_in: public std::num_get { public: explicit gnu_num_get_in(size_t refs = 0) - : std::num_get(refs) { } + : std::num_get(refs) { } }; -class gnu_num_put_out: public std::num_put +class gnu_num_put_out: public std::num_put { public: explicit gnu_num_put_out(size_t refs = 0) - : std::num_put(refs) { } + : std::num_put(refs) { } }; class gnu_time_get_byname: public std::time_get_byname @@ -164,12 +123,12 @@ public: : std::time_get_byname(c, refs) { } }; -class gnu_time_get_in: public std::time_get +class gnu_time_get_in: public std::time_get { public: explicit gnu_time_get_in(size_t refs = 0) - : std::time_get(refs) { } + : std::time_get(refs) { } }; class gnu_time_put_byname: public std::time_put_byname @@ -180,12 +139,12 @@ public: : std::time_put_byname(c, refs) { } }; -class gnu_time_put_out: public std::time_put +class gnu_time_put_out: public std::time_put { public: explicit gnu_time_put_out(size_t refs = 0) - : std::time_put(refs) { } + : std::time_put(refs) { } }; class gnu_messages_byname: public std::messages_byname @@ -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(loc) ); - const ccodecvt& cvt01 = use_facet(cloc); - const gnu_codecvt& cvt02 = use_facet(loc); - // VERIFY( cvt01.id != cvt02.id ); // XXX no way to do this, really :( + try + { const ccodecvt& cvt01 = use_facet(cloc); } + catch(...) + { VERIFY( false ); } + + try + { const gnu_codecvt& cvt02 = use_facet(loc); } + catch(...) + { VERIFY( false ); } + + try + { const ccodecvt& cvt03 = use_facet(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 + +// 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 +#include + +typedef std::codecvt 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; +}