summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-20 08:30:01 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2001-09-20 08:30:01 +0000
commit88825d882818d439e1fcc53095749b1fb839573a (patch)
tree2a5dcdc28c5a07e9a96570184d62aa77b9a7b0f0 /libstdc++-v3/testsuite
parentc6d7113cdcd4eaf0b3cbdd0a3b949c3d51361052 (diff)
downloadgcc-88825d882818d439e1fcc53095749b1fb839573a.tar.gz
2001-09-19 Benjamin Kosnik <bkoz@redhat.com>
Implement std::time_put. * include/bits/locale_facets.h: Include time_members.h. (__timepunct): New. (time_put): Implement. * include/bits/locale_facets.tcc (do_put): Put generic versions here. * include/bits/localefwd.h: Bump number of facets. * config/locale/time_members_generic.h: New file. * config/locale/time_members_gnu.h: New file. * config/locale/c_locale_generic.h: Include clocale. * src/locale-inst.cc: Add use_facet instantiations for __timepunct. * src/locale.cc: Add __timepunct initializations. * src/localename.cc (locale::_Impl::_Impl(string, size_t)): Same. * include/Makefile.am (stamp-target): Add time_members.h. * include/Makefile.in: Regenerate. * acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): Add CTIME_H. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/22_locale/time_put.cc: New file. * testsuite/22_locale/time_put_members_char.cc: New file. * docs/html/22_locale/locale.html: Add note. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45702 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/22_locale/time_put.cc52
-rw-r--r--libstdc++-v3/testsuite/22_locale/time_put_members_char.cc141
-rw-r--r--libstdc++-v3/testsuite/Makefile.in23
3 files changed, 207 insertions, 9 deletions
diff --git a/libstdc++-v3/testsuite/22_locale/time_put.cc b/libstdc++-v3/testsuite/22_locale/time_put.cc
new file mode 100644
index 00000000000..b7318634bb0
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/time_put.cc
@@ -0,0 +1,52 @@
+// 2001-09-17 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001 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.2.5.3 Template class time_put
+
+#include <locale>
+
+void test01()
+{
+ // Check for required base class.
+ typedef std::time_put<char> test_type;
+ typedef std::locale::facet base_type;
+ const test_type& obj = std::use_facet<test_type>(std::locale());
+ const base_type* base = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::iter_type iter_type;
+}
+
+// Should be able to instantiate this for other types besides char, wchar_t
+class gnu_time_put: public std::time_put<unsigned char>
+{ };
+
+void test02()
+{
+ gnu_time_put facet01;
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/time_put_members_char.cc b/libstdc++-v3/testsuite/22_locale/time_put_members_char.cc
new file mode 100644
index 00000000000..995e16857f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/time_put_members_char.cc
@@ -0,0 +1,141 @@
+// 2001-09-17 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001 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.2.5.3.1 time_put members
+
+#include <locale>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// test string version
+void test01()
+{
+ using namespace std;
+ typedef ostreambuf_iterator<char> iterator_type;
+
+ bool test = true;
+
+ // basic construction and sanity checks.
+ locale loc_c = locale::classic();
+ locale loc_hk("en_HK");
+ locale loc_fr("fr_FR@euro");
+ locale loc_de("de_DE");
+ VERIFY( loc_hk != loc_c );
+ VERIFY( loc_hk != loc_fr );
+ VERIFY( loc_hk != loc_de );
+ VERIFY( loc_de != loc_fr );
+
+ // cache the moneypunct facets, for quicker gdb inspection
+ const time_put<char>& timp_c = use_facet<time_put<char> >(loc_c);
+ const time_put<char>& timp_de = use_facet<time_put<char> >(loc_de);
+ const time_put<char>& timp_hk = use_facet<time_put<char> >(loc_hk);
+ const time_put<char>& timp_fr = use_facet<time_put<char> >(loc_fr);
+
+ // create an ostream-derived object, cache the time_put facet
+ const string empty;
+ ostringstream oss;
+ const time_put<char>& tim_put = use_facet<time_put<char> >(oss.getloc());
+
+ // create "C" time objects
+ tm time1 = { 0, 0, 12, 4, 3, 71 };
+ const char* all = "%a %A %b %B %c %d %H %I %j %m %M %p %s %U "
+ "%w %W %x %X %y %Y %Z %%";
+ const char* date = "%A, the second of %B";
+ const char* date_ex = "%Ex";
+
+ // 1
+ // iter_type
+ // put(iter_type s, ios_base& str, char_type fill, const tm* t,
+ // char format, char modifier = 0) const;
+ oss.str(empty);
+ oss.imbue(loc_c);
+ iterator_type os_it01 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
+ string result1 = oss.str();
+ VERIFY( result1 == "Sun" );
+
+ oss.str(empty);
+ oss.imbue(loc_de);
+ iterator_type os_it02 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
+ string result2 = oss.str();
+ VERIFY( result2 == "Son" );
+
+ oss.str(empty);
+ oss.imbue(loc_hk);
+ iterator_type os_it03 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
+ string result3 = oss.str();
+ VERIFY( result3 == "Sun" );
+
+ oss.str(empty);
+ oss.imbue(loc_fr);
+ iterator_type os_it04 = tim_put.put(oss.rdbuf(), oss, '*', &time1, 'a');
+ string result4 = oss.str();
+ VERIFY( result4 == "dim" );
+
+ // 2
+ oss.str(empty);
+ oss.imbue(loc_c);
+ iterator_type os_it05 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date, date + strlen(date));
+ string result5 = oss.str();
+ VERIFY( result5 == "Sunday, the second of April");
+ iterator_type os_it06 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date_ex, date_ex + strlen(date));
+ string result6 = oss.str();
+ VERIFY( result6 != result5 );
+
+ oss.str(empty);
+ oss.imbue(loc_de);
+ iterator_type os_it07 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date, date + strlen(date));
+ string result7 = oss.str();
+ VERIFY( result7 == "Sonntag, the second of April");
+ iterator_type os_it08 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date_ex, date_ex + strlen(date));
+ string result8 = oss.str();
+ VERIFY( result8 != result7 );
+
+ oss.str(empty);
+ oss.imbue(loc_hk);
+ iterator_type os_it09 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date, date + strlen(date));
+ string result9 = oss.str();
+ VERIFY( result9 == "Sunday, the second of April");
+ iterator_type os_it10 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date_ex, date_ex + strlen(date));
+ string result10 = oss.str();
+ VERIFY( result10 != result9 );
+
+ oss.str(empty);
+ oss.imbue(loc_fr);
+ iterator_type os_it11 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date, date + strlen(date));
+ string result11 = oss.str();
+ VERIFY( result11 == "dimanche, the second of avril");
+ iterator_type os_it12 = tim_put.put(oss.rdbuf(), oss, '*', &time1,
+ date_ex, date_ex + strlen(date));
+ string result12 = oss.str();
+ VERIFY( result12 != result11 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in
index 04867cbecd0..24a64d6eb29 100644
--- a/libstdc++-v3/testsuite/Makefile.in
+++ b/libstdc++-v3/testsuite/Makefile.in
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -67,6 +67,7 @@ AR = @AR@
AS = @AS@
ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@
BASIC_FILE_H = @BASIC_FILE_H@
+BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
@@ -77,6 +78,7 @@ CMESSAGES_H = @CMESSAGES_H@
CPP = @CPP@
CSHADOW_FLAGS = @CSHADOW_FLAGS@
CSTDIO_H = @CSTDIO_H@
+CTIME_H = @CTIME_H@
CXX = @CXX@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@
@@ -88,17 +90,17 @@ EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
GENCAT = @GENCAT@
+GLIBC21 = @GLIBC21@
GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
GLIBCPP_IS_CROSS_COMPILING = @GLIBCPP_IS_CROSS_COMPILING@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
-GT_NO = @GT_NO@
-GT_YES = @GT_YES@
-INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
INSTOBJEXT = @INSTOBJEXT@
-INTLDEPS = @INTLDEPS@
+INTLBISON = @INTLBISON@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
+INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
+LIBICONV = @LIBICONV@
LIBIO_INCLUDES = @LIBIO_INCLUDES@
LIBMATHOBJS = @LIBMATHOBJS@
LIBMATH_INCLUDES = @LIBMATH_INCLUDES@
@@ -145,7 +147,6 @@ glibcpp_toolexecdir = @glibcpp_toolexecdir@
glibcpp_toolexeclibdir = @glibcpp_toolexeclibdir@
gxx_include_dir = @gxx_include_dir@
ifGNUmake = @ifGNUmake@
-l = @l@
libio_la = @libio_la@
libtool_VERSION = @libtool_VERSION@
release_VERSION = @release_VERSION@
@@ -155,10 +156,14 @@ AUTOMAKE_OPTIONS = foreign dejagnu
DEJATOOL = libstdc++-v3
-EXPECT = `if [ -f @glibcpp_builddir@/../../expect/expect ] ; then echo @glibcpp_builddir@/../../expect/expect ; else echo expect ; fi`
+EXPECT = `if [ -f @glibcpp_builddir@/../../expect/expect ] ; then \
+ echo @glibcpp_builddir@/../../expect/expect ; \
+ else echo expect ; fi`
-RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then echo @glibcpp_srcdir@/../dejagnu/runtest ; else echo runtest; fi`
+RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then \
+ echo @glibcpp_srcdir@/../dejagnu/runtest ; \
+ else echo runtest; fi`
RUNTESTFLAGS =