You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2007/06/27 01:58:55 UTC
svn commit: r550991 [22/23] - in /incubator/stdcxx/branches/4.2.0: ./ doc/
doc/stdlibref/ doc/stdlibug/ etc/config/ etc/config/src/
etc/config/windows/ etc/nls/ etc/nls/posix/charmaps/ etc/nls/posix/src/
examples/include/ examples/manual/ examples/manu...
Modified: incubator/stdcxx/branches/4.2.0/tests/include/rw_allocator.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/rw_allocator.h?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/include/rw_allocator.h (original)
+++ incubator/stdcxx/branches/4.2.0/tests/include/rw_allocator.h Tue Jun 26 16:58:07 2007
@@ -6,22 +6,23 @@
*
***************************************************************************
*
- * Copyright 2006 The Apache Software Foundation or its licensors,
- * as applicable.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
*
- * Copyright 2006 Rogue Wave Software.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 2006 Rogue Wave Software.
*
**************************************************************************/
@@ -170,8 +171,6 @@
pal_->funcall (pal_->m_cpy_ctor);
}
-#ifndef _RWSTD_NO_INLINE_MEMBER_TEMPLATES
-
template <class U>
UserAlloc (const UserAlloc<U> &rhs) _THROWS (())
: pal_ (rhs.pal_) {
@@ -187,8 +186,6 @@
template <class U>
struct rebind { typedef UserAlloc<U> other; };
-
-#endif // _RWSTD_NO_INLINE_MEMBER_TEMPLATES
void operator= (const UserAlloc &rhs) {
pal_->funcall (pal_->m_cpy_assign, rhs.pal_);
Modified: incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h (original)
+++ incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h Tue Jun 26 16:58:07 2007
@@ -2,7 +2,7 @@
*
* localedef.h - declarations of locale testsuite helpers
*
- * $Id:$
+ * $Id$
*
************************************************************************
*
@@ -62,6 +62,34 @@
// returned from prior calls
_TEST_EXPORT const char*
rw_localedef (const char*, const char*, const char*, const char*);
+
+
+// an array of multibyte characters 1 to MB_LEN_MAX bytes in length
+typedef char
+rw_mbchar_array_t [_RWSTD_MB_LEN_MAX][_RWSTD_MB_LEN_MAX];
+
+// fills consecutive elements of the `mb_chars' array with multibyte
+// characters between 1 and MB_CUR_MAX bytes long for the currently
+// set locale
+// returns the number of elements populated (normally, MB_CUR_MAX)
+_TEST_EXPORT _RWSTD_SIZE_T
+rw_get_mb_chars (rw_mbchar_array_t /* mb_chars */);
+
+
+// finds the multibyte locale with the largest MB_CUR_MAX value and
+// fills consecutive elements of the `mb_chars' array with multibyte
+// characters between 1 and MB_CUR_MAX bytes long for such a locale
+_TEST_EXPORT const char*
+rw_find_mb_locale (_RWSTD_SIZE_T* /* mb_cur_max */,
+ rw_mbchar_array_t /* mb_chars */);
+
+// invokes localedef with charmap and locale def to create a locale database
+// in a directory specified by the RWSTD_LOCALE_ROOT environment
+// variable, if it is defined, otherwise in the current working
+// directory
+// returns the name of the locale
+_TEST_EXPORT const char*
+rw_create_locale (const char *charmap, const char *locale);
#endif // RW_LOCALE_H_INCLUDED
Modified: incubator/stdcxx/branches/4.2.0/tests/include/rw_printf.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/rw_printf.h?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/include/rw_printf.h (original)
+++ incubator/stdcxx/branches/4.2.0/tests/include/rw_printf.h Tue Jun 26 16:58:07 2007
@@ -6,16 +6,23 @@
*
************************************************************************
*
- * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave
- * Software division. Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0. Unless required by
- * applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- * CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1994-2006 Rogue Wave Software.
*
**************************************************************************/
Modified: incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h (original)
+++ incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h Tue Jun 26 16:58:07 2007
@@ -6,16 +6,23 @@
*
************************************************************************
*
- * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave
- * Software division. Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0. Unless required by
- * applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- * CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 2005-2006 Rogue Wave Software.
*
**************************************************************************/
@@ -31,12 +38,13 @@
struct rw_thread_t
{
- long threadno;
- long id;
- void* handle;
+ long threadno; // 0-based unique thread number
+ long id; // thread id
+ void* handle; // thread handle
};
+// same as POSIX pthread_create()
_TEST_EXPORT int
rw_thread_create (rw_thread_t*,
rw_thread_attr_t*,
@@ -44,15 +52,24 @@
void*);
+// same as POSIX pthread_join()
_TEST_EXPORT int
rw_thread_join (rw_thread_t, void**);
+// create a pool of nthreads, passing each a successive element
+// of argarray as argument (if non-null) and filling the tidarray
+// array with their id's; if tidarray is null, waits for all
+// threads to join and fills the aragarray with the result
+// returned from each thread
+// returns 0 on success, or a non-zero value indicating the thread
+// number that failed to create on error
_TEST_EXPORT int
-rw_thread_pool (rw_thread_t*, _RWSTD_SIZE_T,
- rw_thread_attr_t*,
- void* (*)(void*),
- void**);
+rw_thread_pool (rw_thread_t* /* tidarray */,
+ _RWSTD_SIZE_T /* nthreads */,
+ rw_thread_attr_t* /* attr */,
+ void* (*)(void*) /* thr_proc */,
+ void** /* argarray */);
} // extern "C"
Modified: incubator/stdcxx/branches/4.2.0/tests/include/valcmp.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/valcmp.h?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/include/valcmp.h (original)
+++ incubator/stdcxx/branches/4.2.0/tests/include/valcmp.h Tue Jun 26 16:58:07 2007
@@ -6,16 +6,23 @@
*
************************************************************************
*
- * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave
- * Software division. Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0. Unless required by
- * applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- * CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1994-2006 Rogue Wave Software.
*
**************************************************************************/
Modified: incubator/stdcxx/branches/4.2.0/tests/iostream/27.objects.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/iostream/27.objects.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/iostream/27.objects.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/iostream/27.objects.cpp Tue Jun 26 16:58:07 2007
@@ -6,16 +6,23 @@
*
***************************************************************************
*
- * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave
- * Software division. Licensed under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0. Unless required by
- * applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- * CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under
- * the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1994-2006 Rogue Wave Software.
*
**************************************************************************/
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.length.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.length.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.length.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.length.cpp Tue Jun 26 16:58:07 2007
@@ -43,7 +43,7 @@
#include <cmdopt.h> // for rw_enabled()
#include <driver.h> // for rw_test()
#include <file.h> // for rw_fwrite()
-#include <rw_locale.h> // for rw_localedef()
+#include <rw_locale.h> // for rw_localedef(), rw_find_mb_locale()
#include <rw_printf.h> // for rw_printf()
/****************************************************************************/
@@ -116,185 +116,6 @@
return locname;
}
-
-// finds a multibyte character that is `bytes' long if `bytes' is less
-// than or equal to MB_CUR_MAX, or the longest multibyte sequence in
-// the current locale
-const char* get_mb_char (char *buf, std::size_t bytes)
-{
- _RWSTD_ASSERT (0 != buf);
-
- *buf = '\0';
-
- if (0 == bytes)
- return buf;
-
- const bool exact = bytes <= std::size_t (MB_CUR_MAX);
-
- if (!exact)
- bytes = MB_CUR_MAX;
-
- wchar_t wc;
-
- // search the first 64K characters sequentially
- for (wc = wchar_t (1); wc != wchar_t (0xffff); ++wc) {
-
- if ( int (bytes) == std::wctomb (buf, wc)
- && int (bytes) == std::mblen (buf, bytes)) {
- // NUL-terminate the multibyte character of the requested length
- buf [bytes] = '\0';
- break;
- }
-
- *buf = '\0';
- }
-
-#if 2 < _RWSTD_WCHAR_T_SIZE
-
- // if a multibyte character of the requested size is not found
- // in the low 64K range, try to find one using a random search
- if (wchar_t (0xffff) == wc) {
-
- // iterate only so many times to prevent an infinite loop
- // in case when MB_CUR_MAX is greater than the longest
- // multibyte character
- for (int i = 0; i != 0x100000; ++i) {
-
- wc = wchar_t (std::rand ());
-
- if (RAND_MAX < 0x10000) {
- wc <<= 16;
- wc |= wchar_t (std::rand ());
- }
-
- if ( int (bytes) == std::wctomb (buf, wc)
- && int (bytes) == std::mblen (buf, bytes)) {
- // NUL-terminate the multibyte character
- buf [bytes] = '\0';
- break;
- }
-
- *buf = '\0';
- }
- }
-
-#endif // 2 < _RWSTD_WCHAR_SIZE
-
- // return 0 on failure to find a sequence exactly `bytes' long
- return !exact || bytes == std::strlen (buf) ? buf : 0;
-}
-
-
-typedef char mb_char_array_t [MB_LEN_MAX][MB_LEN_MAX];
-
-// fills consecutive elemenets of the `mb_chars' array with multibyte
-// characters between 1 and MB_CUR_MAX bytes long for the given locale
-// returns the number of elements populated (normally, MB_CUR_MAX)
-std::size_t get_mb_chars (mb_char_array_t mb_chars)
-{
- _RWSTD_ASSERT (0 != mb_chars);
-
- const char* mbc = get_mb_char (mb_chars [0], std::size_t (-1));
-
- if (!mbc) {
- rw_fprintf (rw_stderr, "*** failed to find any multibyte characters "
- "in locale \"%s\" with MB_CUR_MAX = %u\n",
- std::setlocale (LC_CTYPE, 0), MB_CUR_MAX);
- return 0;
- }
-
- std::size_t mb_cur_max = std::strlen (mbc);
-
- if (MB_LEN_MAX < mb_cur_max)
- mb_cur_max = MB_LEN_MAX;
-
- // fill each element of `mb_chars' with a multibyte character
- // of the corresponding length
- for (std::size_t i = mb_cur_max; i; --i) {
-
- // try to generate a multibyte character `i' bytes long
- mbc = get_mb_char (mb_chars [i - 1], i);
-
- if (0 == mbc) {
- if (i < mb_cur_max) {
- rw_fprintf (rw_stderr, "*** failed to find %u-byte characters "
- "in locale \"%s\" with MB_CUR_MAX = %u\n",
- i + 1, std::setlocale (LC_CTYPE, 0), MB_CUR_MAX);
- mb_cur_max = 0;
- break;
- }
- --mb_cur_max;
- }
- }
-
- return mb_cur_max;
-}
-
-
-// finds the multibyte locale with the largest MB_CUR_MAX value and
-// fills consecutive elemenets of the `mb_chars' array with multibyte
-// characters between 1 and MB_CUR_MAX bytes long for such a locale
-const char* find_mb_locale (std::size_t *mb_cur_max, mb_char_array_t mb_chars)
-{
- _RWSTD_ASSERT (0 != mb_cur_max);
- _RWSTD_ASSERT (0 != mb_chars);
-
- if (2 > MB_LEN_MAX) {
- rw_fprintf (rw_stderr, "MB_LEN_MAX = %d, giving up\n", MB_LEN_MAX);
- return 0;
- }
-
- static const char *mb_locale_name;
-
- char saved_locale_name [1024];
- std::strcpy (saved_locale_name, std::setlocale (LC_CTYPE, 0));
-
- _RWSTD_ASSERT (std::strlen (saved_locale_name) < sizeof saved_locale_name);
-
- *mb_cur_max = 0;
-
- // iterate over all installed locales
- for (const char *name = rw_locales (_RWSTD_LC_CTYPE, 0); *name;
- name += std::strlen (name) + 1) {
-
- if (std::setlocale (LC_CTYPE, name)) {
-
- // try to generate a set of multibyte characters
- // with lengths from 1 and MB_CUR_MAX (or less)
- const std::size_t cur_max = get_mb_chars (mb_chars);
-
- if (*mb_cur_max < cur_max) {
- *mb_cur_max = cur_max;
- mb_locale_name = name;
-
- // break when we've found a multibyte locale
- // with the longest possible encoding
- if (MB_LEN_MAX == *mb_cur_max)
- break;
- }
- }
- }
-
- if (*mb_cur_max < 2) {
- rw_fprintf (rw_stderr, "*** failed to find a full set of multibyte "
- "characters in locale \"%s\" with MB_CUR_MAX = %u "
- "(computed)", mb_locale_name, *mb_cur_max);
- mb_locale_name = 0;
- }
- else {
- // (re)generate the multibyte characters for the saved locale
- // as they may have been overwritten in subsequent iterations
- // of the loop above (while searching for a locale with greater
- // value of MB_CUR_MAX)
- std::setlocale (LC_CTYPE, mb_locale_name);
- get_mb_chars (mb_chars);
- }
-
- std::setlocale (LC_CTYPE, saved_locale_name);
-
- return mb_locale_name;
-}
-
/****************************************************************************/
template <class internT>
@@ -654,9 +475,9 @@
std::size_t mb_cur_max = 0;
- mb_char_array_t mb_chars;
+ rw_mbchar_array_t mb_chars;
- const char* const locname = find_mb_locale (&mb_cur_max, mb_chars);
+ const char* const locname = rw_find_mb_locale (&mb_cur_max, mb_chars);
if (!rw_warn (0 != locname, 0, __LINE__,
"failed to find a multibyte locale")) {
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp Tue Jun 26 16:58:07 2007
@@ -273,7 +273,7 @@
*mb_cur_max = 0;
// iterate over all installed locales
- for (const char *name = rw_locales (); *name;
+ for (const char *name = rw_locales (); name && *name;
name += std::strlen (name) + 1) {
if (std::setlocale (LC_CTYPE, name)) {
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.ctype.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.ctype.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.ctype.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.ctype.cpp Tue Jun 26 16:58:07 2007
@@ -80,7 +80,7 @@
#define BEGIN_LOCALE_LOOP(num, locname, loop_cntrl) \
for (const char* locname = rw_locales (LC_CTYPE, 0); \
- *locname; locname += std::strlen (locname) + 1) { \
+ locname && *locname; locname += std::strlen (locname) + 1) { \
_TRY { \
const std::locale loc (locname); \
const std::ctype<char> &ctc = \
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp Tue Jun 26 16:58:07 2007
@@ -158,6 +158,9 @@
{
const char *name = rw_locales (LC_ALL, "");
+ if (!name)
+ return 0;
+
char namebuf [256];
// get the full name of the "C" locale for comparison with aliases
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.money.get.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.money.get.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.money.get.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.money.get.cpp Tue Jun 26 16:58:07 2007
@@ -30,13 +30,11 @@
#include <locale>
#include <cstdio> // for sscanf()
-#include <cstdlib> // for mbstowcs(), wcstombs()
-#include <cstring> // for strcat(), strlen()
-#include <cwchar> // for wcslen()
#include <cmdopt.h> // for rw_enabled()
#include <driver.h> // for rw_assert(), rw_test(), ...
-#include <valcmp.h> // for rw_fltcmp()
+#include <rw_char.h> // for rw_expand()
+#include <valcmp.h> // for rw_ldblcmp()
#ifndef _RWSTD_NO_LONG_DOUBLE
@@ -105,105 +103,127 @@
/**************************************************************************/
+template <class charT>
+struct PunctData
+{
+ static charT decimal_point_ [2];
+ static charT thousands_sep_ [2];
+ static const char *grouping_ [2];
+ static const charT *curr_symbol_ [2];
+ static const charT *positive_sign_ [2];
+ static const charT *negative_sign_ [2];
+ static std::money_base::pattern format_ [2][2];
+ static int frac_digits_ [2];
+};
+
+
+template <class charT>
+const char*
+PunctData<charT>::grouping_ [2] = { "", "" };
+
+template <class charT>
+charT
+PunctData<charT>::decimal_point_ [2] = { '.', '.' };
+
+template <class charT>
+charT
+PunctData<charT>::thousands_sep_ [2] = { ',', ',' };
+
+template <class charT>
+const charT*
+PunctData<charT>::curr_symbol_ [2];
+
+template <class charT>
+const charT*
+PunctData<charT>::positive_sign_ [2];
+
+template <class charT>
+const charT*
+PunctData<charT>::negative_sign_ [2];
+
+template <class charT>
+std::money_base::pattern PunctData<charT>::format_ [2][2] = {
+ { // local
+ { { // positive
+ std::money_base::symbol, std::money_base::sign,
+ std::money_base::none, std::money_base::value
+ } },
+ { { // negative
+ std::money_base::symbol, std::money_base::sign,
+ std::money_base::none, std::money_base::value
+ } }
+ },
+
+ { // international
+ { { // positive
+ std::money_base::symbol, std::money_base::sign,
+ std::money_base::none, std::money_base::value
+ } },
+ { { // negative
+ std::money_base::symbol, std::money_base::sign,
+ std::money_base::none, std::money_base::value
+ } }
+ }
+};
+
+template <class charT>
+int PunctData<charT>::frac_digits_ [2];
+
+
template <class charT, bool Intl>
-struct Punct: std::moneypunct<charT, Intl>
+struct Punct: std::moneypunct<charT, Intl>, PunctData<charT>
{
typedef std::moneypunct<charT, Intl> Base;
typedef typename Base::char_type char_type;
typedef typename Base::string_type string_type;
- static char_type decimal_point_;
- static char_type thousands_sep_;
- static const char *grouping_;
- static const char_type *curr_symbol_;
- static const char_type *positive_sign_;
- static const char_type *negative_sign_;
- static std::money_base::pattern format_ [2];
- static int frac_digits_;
-
static int n_thousands_sep_; // number of calls to do_thousands_sep()
Punct (std::size_t ref): Base (ref) { }
char_type do_decimal_point () const {
- return decimal_point_;
+ return this->decimal_point_ [Intl];
}
int do_frac_digits () const {
- return frac_digits_;
+ return this->frac_digits_ [Intl];
}
virtual string_type do_curr_symbol () const {
foo ();
- return curr_symbol_ ? curr_symbol_ : string_type ();
+ return this->curr_symbol_ [Intl] ?
+ this->curr_symbol_ [Intl] : string_type ();
}
virtual std::string do_grouping () const {
- return grouping_ ? std::string (grouping_) : std::string ();
+ return this->grouping_ [Intl] ? this->grouping_ [Intl] : "";
}
virtual char_type do_thousands_sep () const {
++n_thousands_sep_;
- return thousands_sep_;
+ return this->thousands_sep_ [Intl];
}
virtual string_type do_positive_sign () const {
- return positive_sign_ ? positive_sign_ : string_type ();
+ return this->positive_sign_ [Intl] ?
+ this->positive_sign_ [Intl] : string_type ();
}
virtual string_type do_negative_sign () const {
- return negative_sign_ ? negative_sign_ : string_type ();
+ return this->negative_sign_ [Intl] ?
+ this->negative_sign_ [Intl] : string_type ();
}
virtual std::money_base::pattern do_pos_format () const {
- return format_ [0];
+ return this->format_ [Intl][0];
}
virtual std::money_base::pattern do_neg_format () const {
- return format_ [1];
+ return this->format_ [Intl][1];
}
};
template <class charT, bool Intl>
-const char* Punct<charT, Intl>::grouping_ = "";
-
-template <class charT, bool Intl>
-typename Punct<charT, Intl>::char_type
-Punct<charT, Intl>::decimal_point_ = '.';
-
-template <class charT, bool Intl>
-typename Punct<charT, Intl>::char_type
-Punct<charT, Intl>::thousands_sep_ = ',';
-
-template <class charT, bool Intl>
-const typename Punct<charT, Intl>::char_type*
-Punct<charT, Intl>::curr_symbol_;
-
-template <class charT, bool Intl>
-const typename Punct<charT, Intl>::char_type*
-Punct<charT, Intl>::positive_sign_;
-
-template <class charT, bool Intl>
-const typename Punct<charT, Intl>::char_type*
-Punct<charT, Intl>::negative_sign_;
-
-template <class charT, bool Intl>
-std::money_base::pattern Punct<charT, Intl>::format_[2] = {
- { { // positive
- std::money_base::symbol, std::money_base::sign,
- std::money_base::none, std::money_base::value
- } },
- { { // negative
- std::money_base::symbol, std::money_base::sign,
- std::money_base::none, std::money_base::value
- } }
-};
-
-template <class charT, bool Intl>
-int Punct<charT, Intl>::frac_digits_;
-
-
-template <class charT, bool Intl>
int Punct<charT, Intl>::n_thousands_sep_;
@@ -221,72 +241,6 @@
/**************************************************************************/
-const char* narrow (char *dst, const char *src)
-{
- if (src == dst || !src || !dst)
- return src;
-
- std::memcpy (dst, src, std::strlen (src) + 1);
- return dst;
-}
-
-
-const char* widen (char *dst, const char *src)
-{
- if (src == dst || !src || !dst)
- return src;
-
- std::memcpy (dst, src, std::strlen (src) + 1);
- return dst;
-}
-
-
-const char* narrow (char *dst, const wchar_t *src)
-{
- static char buf [4096];
-
- if (!src)
- return 0;
-
- if (!dst)
- dst = buf;
-
- std::size_t len = std::wcslen (src);
-
- RW_ASSERT (len < sizeof buf);
-
- len = std::wcstombs (dst, src, sizeof buf / sizeof *buf);
-
- if (std::size_t (-1) == len)
- *dst = 0;
-
- return dst;
-}
-
-
-const wchar_t* widen (wchar_t *dst, const char *src)
-{
- static wchar_t buf [4096];
-
- if (!src)
- return 0;
-
- if (!dst)
- dst = buf;
-
- std::size_t len = std::strlen (src);
-
- RW_ASSERT (len < sizeof buf /sizeof *buf);
-
- len = std::mbstowcs (dst, src, sizeof buf / sizeof *buf);
-
- if (std::size_t (-1) == len)
- *dst = 0;
-
- return dst;
-}
-
-
template <class charT>
void do_test (charT which, // which overload to exercise
const char *cname, // the name of the charT type
@@ -318,21 +272,35 @@
fmat = pat.field;
}
+ // local format? (the opposite of interantional)
+ const bool locl = !intl;
+
// take care to initialize Punct static data before installing
// the facet in case locale or the base facet calls the overridden
// virtuals early to cache the results
- Punct<charT, false>::format_ [1].field [0] = fmat [0];
- Punct<charT, false>::format_ [1].field [1] = fmat [1];
- Punct<charT, false>::format_ [1].field [2] = fmat [2];
- Punct<charT, false>::format_ [1].field [3] = fmat [3];
+ PunctData<charT>::format_ [intl][1].field [0] = fmat [0];
+ PunctData<charT>::format_ [intl][1].field [1] = fmat [1];
+ PunctData<charT>::format_ [intl][1].field [2] = fmat [2];
+ PunctData<charT>::format_ [intl][1].field [3] = fmat [3];
+
+ PunctData<charT>::format_ [locl][1].field [0] = fmat [3];
+ PunctData<charT>::format_ [locl][1].field [1] = fmat [2];
+ PunctData<charT>::format_ [locl][1].field [2] = fmat [1];
+ PunctData<charT>::format_ [locl][1].field [3] = fmat [0];
// zero out positive format (not used by money_get)
- Punct<charT, false>::format_ [0] = std::money_base::pattern ();
+ PunctData<charT>::format_ [intl][0] = std::money_base::pattern ();
+ PunctData<charT>::format_ [locl][0] = std::money_base::pattern ();
+
+ // expand (widen) currency symbol
+ PunctData<charT>::curr_symbol_ [intl] = rw_expand ((charT*)0, cursym);
+ PunctData<charT>::curr_symbol_ [locl] = 0;
+
+ PunctData<charT>::grouping_ [intl] = grouping;
+ PunctData<charT>::grouping_ [locl] = 0;
- charT wcursym_buf [40];
- Punct<charT, false>::curr_symbol_ = widen (wcursym_buf, cursym);
- Punct<charT, false>::grouping_ = grouping;
- Punct<charT, false>::frac_digits_ = frac_digits;
+ PunctData<charT>::frac_digits_ [intl] = frac_digits;
+ PunctData<charT>::frac_digits_ [locl] = frac_digits + 1;
Ios<charT> io;
MoneyGet<charT> mg;
@@ -351,9 +319,8 @@
io.flags (std::ios_base::fmtflags (flags));
- // widen input string if necessary
- charT wstr_buf [4096];
- const charT *next = widen (wstr_buf, str);
+ // expand (widen) input sequence
+ const charT* const next = rw_expand ((charT*)0, str);
std::ios_base::iostate err = std::ios_base::goodbit;
@@ -374,21 +341,21 @@
!(-1 != consumed && last - next != consumed || err != err_expect);
rw_assert (success, __FILE__, lineno,
- "money_get<%s>::get (%s, ..., %d, ..., %s&), "
+ "money_get<%s>::get (%{*Ac}, ..., %b, ..., %s&), "
"ate %d, expected %d, frac_digits = %d, "
"flags = %{If}, grouping = %#s, pattern = %{LM}, "
- "state = %{Is}, expected = %{Is}",
- cname, next, intl, tname,
+ "state = %{Is}, expected %{Is}",
+ cname, int (sizeof *next), next, intl, tname,
last - next, consumed, frac_digits,
flags, grouping, fmat,
err, err_expect);
rw_assert (2 > rw_ldblcmp (x, val), __FILE__, lineno,
- "money_get<%s>::get (%s, ..., %d, ..., %s&), "
+ "money_get<%s>::get (%{*Ac}, ..., %b, ..., %s&), "
"got %Lg, expected %Lg, frac_digits = %d, "
"flags = %{If}s, grouping = %#s, pattern = %{LM}, "
"state = %{Is}, expected %{Is}",
- cname, next, intl, tname,
+ cname, int (sizeof *next), next, intl, tname,
x, val, frac_digits,
flags, grouping, fmat,
err, err_expect);
@@ -406,11 +373,11 @@
!(-1 != consumed && last - next != consumed || err != err_expect);
rw_assert (success, __FILE__, lineno,
- "money_get<%s>::get (%s, ..., %d, ..., "
+ "money_get<%s>::get (%{*Ac}, ..., %b, ..., "
"basic_string<%s>&), ate %d, expected %d, "
"frac_digits = %d, flags = %{If}, grouping = %#s"
- ", format = %{LM}, state = %{Is}, expected = %{Is}",
- cname, next, intl,
+ ", format = %{LM}, state = %{Is}, expected %{Is}",
+ cname, int (sizeof *next), next, intl,
cname, last - next, consumed,
frac_digits, flags, grouping,
fmat, err, err_expect);
@@ -418,7 +385,7 @@
if (success) {
char narrow_buf [4096];
- narrow (narrow_buf, bs.c_str ());
+ rw_narrow (narrow_buf, bs.c_str ());
LongDouble x = 0;
@@ -434,16 +401,19 @@
&& 1 < rw_ldblcmp (x, val));
rw_assert (success, __FILE__, lineno,
- "money_get<%s>::get (%s, ..., %d, ..., "
+ "money_get<%s>::get (%{*Ac}, ..., %b, ..., "
"basic_string<%s>&), got %s, expected %Lg, "
"frac_digits = %d, flags = %{If}, grouping = %#s,"
" pattern = %{LM}, iostate = %{Is}, expected %{Is}",
- cname, next, intl,
+ cname, int (sizeof *next), next, intl,
cname, bs.c_str (), val,
frac_digits, flags, grouping,
fmat, err, err_expect);
}
}
+
+ delete[] PunctData<charT>::curr_symbol_ [intl];
+ delete[] next;
}
/**************************************************************************/
@@ -478,7 +448,7 @@
template <class charT>
-void test_memfun (charT opt, const char *cname, const char *tname)
+void test_get (charT opt, const char *cname, const char *tname)
{
#define T opt, cname, tname, __LINE__
#define TEST do_test
@@ -496,9 +466,12 @@
// by decimal_point(). The other symbols are defined as follows:
// units ::= digits [ thousandssep units ] digits ::= adigit [ digits ]
- Punct<charT, false>::positive_sign_ = 0;
- Punct<charT, false>::negative_sign_ = 0;
- Punct<charT, false>::thousands_sep_ = '\0';
+ PunctData<charT>::positive_sign_ [0] = 0;
+ PunctData<charT>::positive_sign_ [1] = 0;
+ PunctData<charT>::negative_sign_ [0] = 0;
+ PunctData<charT>::negative_sign_ [1] = 0;
+ PunctData<charT>::thousands_sep_ [0] = '\0';
+ PunctData<charT>::thousands_sep_ [1] = '\0';
// parsing zero, no curr_symbol or sign, default pattern, 0 frac_digits
TEST (T, 0.0, "0", 1, 0, eofbit);
@@ -566,7 +539,8 @@
TEST (T, 54321098.0, "5432.1098", 9, 0, eofbit, 4);
TEST (T, 432109870.0, "43210.987", 9, 0, eofbit, 4);
- Punct<charT, false>::thousands_sep_ = ',';
+ PunctData<charT>::thousands_sep_ [0] = ',';
+ PunctData<charT>::thousands_sep_ [1] = ';';
// parsing with thousands_sep and/or grouping
TEST (T, 0.0, "0", 1, 0, eofbit, 0, 0, "", "\1");
@@ -637,11 +611,13 @@
// parsing with a simple non-empty sign
- static const charT plus[] = { '+', '\0' };
- static const charT minus[] = { '-', '\0' };
+ static const charT plus[][2] = { { '+', '\0' }, { '\0' } };
+ static const charT minus[][2] = { { '-', '\0' }, { '\0' } };
- Punct<charT, false>::positive_sign_ = plus;
- Punct<charT, false>::negative_sign_ = minus;
+ PunctData<charT>::positive_sign_ [0] = plus [0];
+ PunctData<charT>::negative_sign_ [0] = minus [0];
+ PunctData<charT>::positive_sign_ [1] = plus [1];
+ PunctData<charT>::negative_sign_ [1] = minus [1];
TEST (T, 15.0, "+15", 3, 0, eofbit, 0, 0, "");
TEST (T, 16.0, "+ 16", 4, 0, eofbit, 0, 0, "");
@@ -668,11 +644,13 @@
// parsing with a multi-char non-empty sign
- static const charT plus_plus[] = { '+', '+', '\0' };
- static const charT minus_minus[] = { '-', '-', '\0' };
+ static const charT plus_plus[][3] = { { '+', '+', '\0' }, { '\0' } };
+ static const charT minus_minus[][3] = { { '-', '-', '\0' }, { '\0' } };
- Punct<charT, false>::positive_sign_ = plus_plus;
- Punct<charT, false>::negative_sign_ = minus_minus;
+ PunctData<charT>::positive_sign_ [0] = plus_plus [0];
+ PunctData<charT>::negative_sign_ [0] = minus_minus [0];
+ PunctData<charT>::positive_sign_ [1] = plus_plus [1];
+ PunctData<charT>::negative_sign_ [1] = minus_minus [1];
TEST (T, 27.0, "+27+", 4, 0, eofbit, 0, 0, "");
TEST (T, 28.0, "+ 28+", 6, 0, eofbit, 0, 0, "");
@@ -703,9 +681,12 @@
TEST (T, 0.0, "$-3.80 -", 3, 0, failbit, 0, 0, "$");
TEST (T, 0.0, "$- 3.91 -", 7, 0, failbit, 1, 0, "$");
- static const charT plus_minus[] = { '+', '-', '\0' };
- Punct<charT, false>::positive_sign_ = plus_plus;
- Punct<charT, false>::negative_sign_ = plus_minus;
+ static const charT plus_minus[][3] = { { '+', '-', '\0' }, { '\0' } };
+
+ PunctData<charT>::positive_sign_ [0] = plus_plus [0];
+ PunctData<charT>::positive_sign_ [1] = plus_plus [1];
+ PunctData<charT>::negative_sign_ [0] = plus_minus [0];
+ PunctData<charT>::negative_sign_ [1] = plus_minus [1];
// 22.2.6.1.2, p3: if the first character of positive
// and negative sign is the same, the result is positive
@@ -721,8 +702,10 @@
// none = 0, space = 1, symbol = 2, sign = 3, value = 4
// test various patterns
- Punct<charT, false>::positive_sign_ = plus;
- Punct<charT, false>::negative_sign_ = minus;
+ PunctData<charT>::positive_sign_ [0] = plus [0];
+ PunctData<charT>::positive_sign_ [1] = plus [1];
+ PunctData<charT>::negative_sign_ [0] = minus [0];
+ PunctData<charT>::negative_sign_ [1] = minus [1];
TEST (T, -100.0, "$-1", 3, showbase, eofbit, 2, "\2\3\4\0", "$");
TEST (T, -200.0, "$-2 ", 3, showbase, goodbit, 2, "\2\3\4\0", "$");
@@ -746,8 +729,9 @@
TEST (T, 0.0, "14$-", 2, showbase, failbit, 2, "\4\1\2\3", "$");
TEST (T, -1500.0, "15 $-", 5, showbase, eofbit, 2, "\4\1\2\3", "$");
- const charT parens[] = { '(', ')', '\0' };
- Punct<charT, false>::negative_sign_ = parens;
+ const charT parens[][3] = { { '(', ')', '\0' }, { '\0' } };
+ PunctData<charT>::negative_sign_ [0] = parens [0];
+ PunctData<charT>::negative_sign_ [1] = parens [1];
// { sign, space, value, symbol }, with symbol required
TEST (T, -90.0, "( 9$)", 5, showbase, eofbit, 1, "\3\1\4\2", "$");
@@ -772,8 +756,10 @@
TEST (T, -104.0, "(104 L)", 7, 0, eofbit, 0, "\3\4\0\2", "L");
TEST (T, -105.0, "(105 L)", 7, showbase, eofbit, 0, "\3\4\0\2", "L");
- Punct<charT, false>::positive_sign_ = plus;
- Punct<charT, false>::negative_sign_ = minus;
+ PunctData<charT>::positive_sign_ [0] = plus [0];
+ PunctData<charT>::negative_sign_ [0] = minus [0];
+ PunctData<charT>::positive_sign_ [1] = plus [1];
+ PunctData<charT>::negative_sign_ [1] = minus [1];
// { sign, value, none, symbol }
// trailing optional curr_symbol or whitespace preceding it (regardless
@@ -797,8 +783,9 @@
// trailing required curr_symbol is consumed
TEST (T, -109.0, "109-$", 5, showbase, eofbit, 0, "\4\0\3\2", "$");
- const charT minus_space[] = { '-', ' ', '\0' };
- Punct<charT, false>::negative_sign_ = minus_space;
+ const charT minus_space[][3] = { { '-', ' ', '\0' }, { '\0' } };
+ PunctData<charT>::negative_sign_ [0] = minus_space [0];
+ PunctData<charT>::negative_sign_ [1] = minus_space [1];
// { sign, value, none, symbol }
// negative_sign is "- ", (note the single trailing space)
@@ -810,24 +797,30 @@
// verify that optional space after value and before currency
// symbol is treated correctly
- Punct<charT, false>::positive_sign_ = plus_plus;
- Punct<charT, false>::negative_sign_ = 0;
+ PunctData<charT>::positive_sign_ [0] = plus_plus [0];
+ PunctData<charT>::positive_sign_ [1] = 0;
+ PunctData<charT>::negative_sign_ [0] = 0;
+ PunctData<charT>::negative_sign_ [1] = 0;
// { sign, value, none, symbol }
TEST (T, 1090.0, "1090 $", 6, showbase, eofbit, 0, "\3\4\0\2", "$");
TEST (T, 1091.0, "1091 $", 6, showbase, eofbit, 0, "\3\4\0\2", "$");
TEST (T, +1092.0, "+1092 $+", 8, showbase, eofbit, 0, "\3\4\0\2", "$");
- Punct<charT, false>::positive_sign_ = 0;
- Punct<charT, false>::negative_sign_ = parens;
+ PunctData<charT>::positive_sign_ [0] = 0;
+ PunctData<charT>::positive_sign_ [1] = 0;
+ PunctData<charT>::negative_sign_ [0] = parens [0];
+ PunctData<charT>::negative_sign_ [1] = 0;
TEST (T, 1093.0, "1093 $", 6, showbase, eofbit, 0, "\3\4\0\2", "$");
TEST (T, 1094.0, "1094 $", 6, showbase, eofbit, 0, "\3\4\0\2", "$");
TEST (T, -1095.0, "(1095 $)", 8, showbase, eofbit, 0, "\3\4\0\2", "$");
// verify a single-char sign with a multichar one (see bug #428)
- Punct<charT, false>::positive_sign_ = plus;
- Punct<charT, false>::negative_sign_ = parens;
+ PunctData<charT>::positive_sign_ [0] = plus [0];
+ PunctData<charT>::positive_sign_ [1] = 0;
+ PunctData<charT>::negative_sign_ [0] = parens [0];
+ PunctData<charT>::negative_sign_ [1] = 0;
// { sign, value, none, symbol }
TEST (T, 1096.0, "1096 $", 6, showbase, eofbit, 0, "\3\4\0\2", "$");
@@ -835,8 +828,10 @@
TEST (T, +1098.0, "+1098 $", 7, showbase, eofbit, 0, "\3\4\0\2", "$");
TEST (T, -1099.0, "(1099 $)", 8, showbase, eofbit, 0, "\3\4\0\2", "$");
- Punct<charT, false>::positive_sign_ = 0;
- Punct<charT, false>::negative_sign_ = 0;
+ PunctData<charT>::positive_sign_ [0] = 0;
+ PunctData<charT>::positive_sign_ [1] = 0;
+ PunctData<charT>::negative_sign_ [0] = 0;
+ PunctData<charT>::negative_sign_ [1] = 0;
// { value, none, symbol, sign }
// trailing whitespace is not extracted (even if required by the format)
@@ -856,9 +851,12 @@
TEST (T, 119.0, "119 $", 5, showbase, eofbit, 0, "\4\1\2\3", "$");
- Punct<charT, false>::positive_sign_ = plus;
- Punct<charT, false>::negative_sign_ = minus;
- Punct<charT, false>::thousands_sep_ = ';';
+ PunctData<charT>::positive_sign_ [0] = plus [0];
+ PunctData<charT>::positive_sign_ [1] = plus [1];
+ PunctData<charT>::negative_sign_ [0] = minus [0];
+ PunctData<charT>::negative_sign_ [1] = minus [1];
+ PunctData<charT>::thousands_sep_ [0] = ';';
+ PunctData<charT>::thousands_sep_ [1] = '*';
// test grouping, default pattern { symbol sign none value }
TEST (T, 0.0, "$0", 2, 0, eofbit, 0, 0, "$", "\1");
@@ -954,8 +952,8 @@
test_long_double (charT, const char *cname)
{
if (rw_enabled ("long double"))
- test_memfun (charT (0 /* long double argument */),
- cname, "long double");
+ test_get (charT (0 /* long double argument */),
+ cname, "long double");
else
rw_note (0, __FILE__, __LINE__, "long double test disabled");
}
@@ -967,8 +965,8 @@
test_string (charT, const char *cname)
{
if (rw_enabled ("basic_string"))
- test_memfun (charT (1 /* basic_string argument */),
- cname, "basic_string");
+ test_get (charT (1 /* basic_string argument */),
+ cname, "basic_string");
else
rw_note (0, __FILE__, __LINE__,
"basic_string<%s> test disabled", cname);
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.get.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.get.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.get.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.get.cpp Tue Jun 26 16:58:07 2007
@@ -192,12 +192,12 @@
virtual string_type do_truename () const {
char_type name [40];
- return rw_widen (name, truename_, sizeof name / sizeof *name);
+ return rw_widen (name, truename_, sizeof name / sizeof *name - 1);
}
virtual string_type do_falsename () const {
char_type name [40];
- return rw_widen (name, falsename_, sizeof name / sizeof *name);
+ return rw_widen (name, falsename_, sizeof name / sizeof *name - 1);
}
};
@@ -266,6 +266,15 @@
return 0;
}
+ if (*grouping && '%' != *grouping && rw_opt_no_grouping) {
+ // if grouping is not empty (and doesn't start with '%')
+ // check the state of the --no-grouping command line
+ // option before proceeding with the test case
+ rw_note (0, __FILE__, __LINE__,
+ "grouping test on line %d disabled", lineno);
+ return 0;
+ }
+
// create a distinct punctuation facet for each iteration to make sure
// any data cached in between successive calls to the facet's public
// member functions are flushed
@@ -436,7 +445,7 @@
const char *iname, // name of iterator type
nativeT val, // value expected to be extracted
const char *str, // input sequence
- int eat_expect = -1, // number of consumed characters
+ int eat_expect = -1, // number of consumed characters
int flags = 0, // initial set of flags
int err_expect = -1, // expected iostate
const char *grouping = "") // optional grouping string
@@ -1571,12 +1580,128 @@
# define LL(number) number ## I64
# endif // _MSC_VER
- TEST (T, LL ( 0), "0", 1, 0, Eof);
- TEST (T, LL ( 0), "+0", 2, 0, Eof);
- TEST (T, LL ( 0), "-0", 2, 0, Eof);
- TEST (T, LL ( 1), "+1", 2, 0, Eof);
- TEST (T, -LL ( 1), "-1", 2, 0, Eof);
- TEST (T, LL (1079), "1079", 4, 0, Eof);
+ TEST (T, LL ( 0), "0", 1, 0, Eof);
+ TEST (T, LL ( 1), "1", 1, 0, Eof);
+ TEST (T, LL ( 12), "12", 2, 0, Eof);
+ TEST (T, LL ( 123), "123", 3, 0, Eof);
+ TEST (T, LL ( 1234), "1234", 4, 0, Eof);
+ TEST (T, LL ( 12345), "12345", 5, 0, Eof);
+ TEST (T, LL ( 123456), "123456", 6, 0, Eof);
+ TEST (T, LL ( 1234567), "1234567", 7, 0, Eof);
+ TEST (T, LL ( 12345678), "12345678", 8, 0, Eof);
+ TEST (T, LL ( 123456789), "123456789", 9, 0, Eof);
+ TEST (T, LL ( 1234567890), "1234567890", 10, 0, Eof);
+ TEST (T, LL ( 12345678901), "12345678901", 11, 0, Eof);
+ TEST (T, LL ( 123456789012), "123456789012", 12, 0, Eof);
+ TEST (T, LL ( 1234567890123), "1234567890123", 13, 0, Eof);
+ TEST (T, LL ( 12345678901234), "12345678901234", 14, 0, Eof);
+ TEST (T, LL ( 123456789012345), "123456789012345", 15, 0, Eof);
+ TEST (T, LL ( 1234567890123456), "1234567890123456", 16, 0, Eof);
+ TEST (T, LL ( 12345678901234567), "12345678901234567", 17, 0, Eof);
+ TEST (T, LL ( 123456789012345678), "123456789012345678", 18, 0, Eof);
+ TEST (T, LL (1234567890123456789), "1234567890123456789", 19, 0, Eof);
+
+ TEST (T, LL ( 0), "0000000000000000000", 19, dec, Eof);
+ TEST (T, LL ( 1), "0000000000000000001", 19, dec, Eof);
+ TEST (T, LL ( 2), "000000000000000002", 18, dec, Eof);
+ TEST (T, LL ( 3), "00000000000000003", 17, dec, Eof);
+ TEST (T, LL ( 4), "0000000000000004", 16, dec, Eof);
+ TEST (T, LL ( 5), "000000000000005", 15, dec, Eof);
+ TEST (T, LL ( 6), "00000000000006", 14, dec, Eof);
+ TEST (T, LL ( 7), "0000000000007", 13, dec, Eof);
+ TEST (T, LL ( 8), "000000000008", 12, dec, Eof);
+ TEST (T, LL ( 9), "00000000009", 11, dec, Eof);
+ TEST (T, LL ( 1), "0000000001", 10, dec, Eof);
+ TEST (T, LL ( 2), "000000002", 9, dec, Eof);
+ TEST (T, LL ( 3), "00000003", 8, dec, Eof);
+ TEST (T, LL ( 4), "0000004", 7, dec, Eof);
+ TEST (T, LL ( 5), "000005", 6, dec, Eof);
+ TEST (T, LL ( 6), "00006", 5, dec, Eof);
+ TEST (T, LL ( 7), "0007", 4, dec, Eof);
+ TEST (T, LL ( 8), "008", 3, dec, Eof);
+ TEST (T, LL ( 9), "09", 2, dec, Eof);
+
+ TEST (T, +LL ( 0), "+0", 2, 0, Eof);
+ TEST (T, +LL ( 1), "+1", 2, 0, Eof);
+ TEST (T, +LL ( 12), "+12", 3, 0, Eof);
+ TEST (T, +LL ( 123), "+123", 4, 0, Eof);
+ TEST (T, +LL ( 1234), "+1234", 5, 0, Eof);
+ TEST (T, +LL ( 12345), "+12345", 6, 0, Eof);
+ TEST (T, +LL ( 123456), "+123456", 7, 0, Eof);
+ TEST (T, +LL ( 1234567), "+1234567", 8, 0, Eof);
+ TEST (T, +LL ( 12345678), "+12345678", 9, 0, Eof);
+ TEST (T, +LL ( 123456789), "+123456789", 10, 0, Eof);
+ TEST (T, +LL ( 1234567890), "+1234567890", 11, 0, Eof);
+ TEST (T, +LL ( 12345678901), "+12345678901", 12, 0, Eof);
+ TEST (T, +LL ( 123456789012), "+123456789012", 13, 0, Eof);
+ TEST (T, +LL ( 1234567890123), "+1234567890123", 14, 0, Eof);
+ TEST (T, +LL ( 12345678901234), "+12345678901234", 15, 0, Eof);
+ TEST (T, +LL ( 123456789012345), "+123456789012345", 16, 0, Eof);
+ TEST (T, +LL ( 1234567890123456), "+1234567890123456", 17, 0, Eof);
+ TEST (T, +LL ( 12345678901234567), "+12345678901234567", 18, 0, Eof);
+ TEST (T, +LL ( 123456789012345678), "+123456789012345678", 19, 0, Eof);
+ TEST (T, +LL (1234567890123456789), "+1234567890123456789", 20, 0, Eof);
+
+ TEST (T, +LL ( 0), "+0000000000000000000", 20, dec, Eof);
+ TEST (T, +LL ( 1), "+0000000000000000001", 20, dec, Eof);
+ TEST (T, +LL ( 2), "+000000000000000002", 19, dec, Eof);
+ TEST (T, +LL ( 3), "+00000000000000003", 18, dec, Eof);
+ TEST (T, +LL ( 4), "+0000000000000004", 17, dec, Eof);
+ TEST (T, +LL ( 5), "+000000000000005", 16, dec, Eof);
+ TEST (T, +LL ( 6), "+00000000000006", 15, dec, Eof);
+ TEST (T, +LL ( 7), "+0000000000007", 14, dec, Eof);
+ TEST (T, +LL ( 8), "+000000000008", 13, dec, Eof);
+ TEST (T, +LL ( 9), "+00000000009", 12, dec, Eof);
+ TEST (T, +LL ( 1), "+0000000001", 11, dec, Eof);
+ TEST (T, +LL ( 2), "+000000002", 10, dec, Eof);
+ TEST (T, +LL ( 3), "+00000003", 9, dec, Eof);
+ TEST (T, +LL ( 4), "+0000004", 8, dec, Eof);
+ TEST (T, +LL ( 5), "+000005", 7, dec, Eof);
+ TEST (T, +LL ( 6), "+00006", 6, dec, Eof);
+ TEST (T, +LL ( 7), "+0007", 5, dec, Eof);
+ TEST (T, +LL ( 8), "+008", 4, dec, Eof);
+ TEST (T, +LL ( 9), "+09", 3, dec, Eof);
+
+ TEST (T, -LL ( 0), "-0", 2, 0, Eof);
+ TEST (T, -LL ( 1), "-1", 2, 0, Eof);
+ TEST (T, -LL ( 12), "-12", 3, 0, Eof);
+ TEST (T, -LL ( 123), "-123", 4, 0, Eof);
+ TEST (T, -LL ( 1234), "-1234", 5, 0, Eof);
+ TEST (T, -LL ( 12345), "-12345", 6, 0, Eof);
+ TEST (T, -LL ( 123456), "-123456", 7, 0, Eof);
+ TEST (T, -LL ( 1234567), "-1234567", 8, 0, Eof);
+ TEST (T, -LL ( 12345678), "-12345678", 9, 0, Eof);
+ TEST (T, -LL ( 123456789), "-123456789", 10, 0, Eof);
+ TEST (T, -LL ( 1234567890), "-1234567890", 11, 0, Eof);
+ TEST (T, -LL ( 12345678901), "-12345678901", 12, 0, Eof);
+ TEST (T, -LL ( 123456789012), "-123456789012", 13, 0, Eof);
+ TEST (T, -LL ( 1234567890123), "-1234567890123", 14, 0, Eof);
+ TEST (T, -LL ( 12345678901234), "-12345678901234", 15, 0, Eof);
+ TEST (T, -LL ( 123456789012345), "-123456789012345", 16, 0, Eof);
+ TEST (T, -LL ( 1234567890123456), "-1234567890123456", 17, 0, Eof);
+ TEST (T, -LL ( 12345678901234567), "-12345678901234567", 18, 0, Eof);
+ TEST (T, -LL ( 123456789012345678), "-123456789012345678", 19, 0, Eof);
+ TEST (T, -LL (1234567890123456789), "-1234567890123456789", 20, 0, Eof);
+
+ TEST (T, -LL ( 0), "-0000000000000000000", 20, dec, Eof);
+ TEST (T, -LL ( 1), "-0000000000000000001", 20, dec, Eof);
+ TEST (T, -LL ( 2), "-000000000000000002", 19, dec, Eof);
+ TEST (T, -LL ( 3), "-00000000000000003", 18, dec, Eof);
+ TEST (T, -LL ( 4), "-0000000000000004", 17, dec, Eof);
+ TEST (T, -LL ( 5), "-000000000000005", 16, dec, Eof);
+ TEST (T, -LL ( 6), "-00000000000006", 15, dec, Eof);
+ TEST (T, -LL ( 7), "-0000000000007", 14, dec, Eof);
+ TEST (T, -LL ( 8), "-000000000008", 13, dec, Eof);
+ TEST (T, -LL ( 9), "-00000000009", 12, dec, Eof);
+ TEST (T, -LL ( 1), "-0000000001", 11, dec, Eof);
+ TEST (T, -LL ( 2), "-000000002", 10, dec, Eof);
+ TEST (T, -LL ( 3), "-00000003", 9, dec, Eof);
+ TEST (T, -LL ( 4), "-0000004", 8, dec, Eof);
+ TEST (T, -LL ( 5), "-000005", 7, dec, Eof);
+ TEST (T, -LL ( 6), "-00006", 6, dec, Eof);
+ TEST (T, -LL ( 7), "-0007", 5, dec, Eof);
+ TEST (T, -LL ( 8), "-008", 4, dec, Eof);
+ TEST (T, -LL ( 9), "-09", 3, dec, Eof);
// LLONG_MAX for a 64-bit long long
TEST (T, +LL (9223372036854775807), "+9223372036854775807", 20, 0, Eof);
@@ -1589,6 +1714,179 @@
// warning: this decimal constant is unsigned only in ISO C90
TEST (T, -LL (9223372036854775807) - 1, "-9223372036854775808", 20, 0, Eof);
+ // exercise hex parsing
+ TEST (T, LL ( 0), "0", 1, hex, Eof);
+ TEST (T, LL ( 0x1), "1", 1, hex, Eof);
+ TEST (T, LL ( 0x12), "12", 2, hex, Eof);
+ TEST (T, LL ( 0x123), "123", 3, hex, Eof);
+ TEST (T, LL ( 0x1234), "1234", 4, hex, Eof);
+ TEST (T, LL ( 0x12345), "12345", 5, hex, Eof);
+ TEST (T, LL ( 0x123456), "123456", 6, hex, Eof);
+ TEST (T, LL ( 0x1234567), "1234567", 7, hex, Eof);
+ TEST (T, LL ( 0x12345678), "12345678", 8, hex, Eof);
+ TEST (T, LL ( 0x123456789), "123456789", 9, hex, Eof);
+ TEST (T, LL ( 0x123456789a), "123456789a", 10, hex, Eof);
+ TEST (T, LL ( 0x123456789ab), "123456789ab", 11, hex, Eof);
+ TEST (T, LL ( 0x123456789abc), "123456789abc", 12, hex, Eof);
+ TEST (T, LL ( 0x123456789abcd), "123456789abcd", 13, hex, Eof);
+ TEST (T, LL ( 0x123456789abcde), "123456789abcde", 14, hex, Eof);
+ TEST (T, LL ( 0x123456789abcdef), "123456789abcdef", 15, hex, Eof);
+ TEST (T, LL ( 0x123456789abcdef0), "123456789abcdef0", 16, hex, Eof);
+
+ TEST (T, LL ( 0), "0x0", 3, hex, Eof);
+ TEST (T, LL ( 0x1), "0x1", 3, hex, Eof);
+ TEST (T, LL ( 0x12), "0x12", 4, hex, Eof);
+ TEST (T, LL ( 0x123), "0x123", 5, hex, Eof);
+ TEST (T, LL ( 0x1234), "0x1234", 6, hex, Eof);
+ TEST (T, LL ( 0x12345), "0x12345", 7, hex, Eof);
+ TEST (T, LL ( 0x123456), "0x123456", 8, hex, Eof);
+ TEST (T, LL ( 0x1234567), "0x1234567", 9, hex, Eof);
+ TEST (T, LL ( 0x12345678), "0x12345678", 10, hex, Eof);
+ TEST (T, LL ( 0x123456789), "0x123456789", 11, hex, Eof);
+ TEST (T, LL ( 0x123456789a), "0x123456789a", 12, hex, Eof);
+ TEST (T, LL ( 0x123456789ab), "0x123456789ab", 13, hex, Eof);
+ TEST (T, LL ( 0x123456789abc), "0x123456789abc", 14, hex, Eof);
+ TEST (T, LL ( 0x123456789abcd), "0x123456789abcd", 15, hex, Eof);
+ TEST (T, LL ( 0x123456789abcde), "0x123456789abcde", 16, hex, Eof);
+ TEST (T, LL ( 0x123456789abcdef), "0x123456789abcdef", 17, hex, Eof);
+ TEST (T, LL ( 0x123456789abcdef0), "0x123456789abcdef0", 18, hex, Eof);
+
+ TEST (T, LL ( 0x0), "00000000000000000000", 20, hex, Eof);
+ TEST (T, LL ( 0x1), "0000000000000000001", 19, hex, Eof);
+ TEST (T, LL ( 0x2), "000000000000000002", 18, hex, Eof);
+ TEST (T, LL ( 0x3), "00000000000000003", 17, hex, Eof);
+ TEST (T, LL ( 0x4), "0000000000000004", 16, hex, Eof);
+ TEST (T, LL ( 0x5), "000000000000005", 15, hex, Eof);
+ TEST (T, LL ( 0x6), "00000000000006", 14, hex, Eof);
+ TEST (T, LL ( 0x7), "0000000000007", 13, hex, Eof);
+ TEST (T, LL ( 0x8), "000000000008", 12, hex, Eof);
+ TEST (T, LL ( 0x9), "00000000009", 11, hex, Eof);
+ TEST (T, LL ( 0xa), "000000000a", 10, hex, Eof);
+ TEST (T, LL ( 0xb), "00000000b", 9, hex, Eof);
+ TEST (T, LL ( 0xc), "0000000c", 8, hex, Eof);
+ TEST (T, LL ( 0xd), "000000d", 7, hex, Eof);
+ TEST (T, LL ( 0xe), "00000e", 6, hex, Eof);
+ TEST (T, LL ( 0xf), "0000f", 5, hex, Eof);
+ TEST (T, LL ( 0x1), "0001", 4, hex, Eof);
+ TEST (T, LL ( 0x2), "002", 3, hex, Eof);
+ TEST (T, LL ( 0x3), "03", 2, hex, Eof);
+ TEST (T, LL ( 0x4), "4", 1, hex, Eof);
+
+ TEST (T, LL ( 0x0), "0x000000000000000000", 20, hex, Eof);
+ TEST (T, LL ( 0x1), "0x00000000000000001", 19, hex, Eof);
+ TEST (T, LL ( 0x2), "0x0000000000000002", 18, hex, Eof);
+ TEST (T, LL ( 0x3), "0x000000000000003", 17, hex, Eof);
+ TEST (T, LL ( 0x4), "0x00000000000004", 16, hex, Eof);
+ TEST (T, LL ( 0x5), "0x0000000000005", 15, hex, Eof);
+ TEST (T, LL ( 0x6), "0x000000000006", 14, hex, Eof);
+ TEST (T, LL ( 0x7), "0x00000000007", 13, hex, Eof);
+ TEST (T, LL ( 0x8), "0x0000000008", 12, hex, Eof);
+ TEST (T, LL ( 0x9), "0x000000009", 11, hex, Eof);
+ TEST (T, LL ( 0xa), "0x0000000a", 10, hex, Eof);
+ TEST (T, LL ( 0xb), "0x000000b", 9, hex, Eof);
+ TEST (T, LL ( 0xc), "0x00000c", 8, hex, Eof);
+ TEST (T, LL ( 0xd), "0x0000d", 7, hex, Eof);
+ TEST (T, LL ( 0xe), "0x000e", 6, hex, Eof);
+ TEST (T, LL ( 0xf), "0x00f", 5, hex, Eof);
+ TEST (T, LL ( 0x1), "0x01", 4, hex, Eof);
+ TEST (T, LL ( 0x2), "0x2", 3, hex, Eof);
+
+ TEST (T, +LL ( 0x0), "+0", 2, hex, Eof);
+ TEST (T, +LL ( 0x1), "+1", 2, hex, Eof);
+ TEST (T, +LL ( 0x12), "+12", 3, hex, Eof);
+ TEST (T, +LL ( 0x123), "+123", 4, hex, Eof);
+ TEST (T, +LL ( 0x1234), "+1234", 5, hex, Eof);
+ TEST (T, +LL ( 0x12345), "+12345", 6, hex, Eof);
+ TEST (T, +LL ( 0x123456), "+123456", 7, hex, Eof);
+ TEST (T, +LL ( 0x1234567), "+1234567", 8, hex, Eof);
+ TEST (T, +LL ( 0x12345678), "+12345678", 9, hex, Eof);
+ TEST (T, +LL ( 0x123456789), "+123456789", 10, hex, Eof);
+ TEST (T, +LL ( 0x123456789a), "+123456789a", 11, hex, Eof);
+ TEST (T, +LL ( 0x123456789ab), "+123456789ab", 12, hex, Eof);
+ TEST (T, +LL ( 0x123456789abc), "+123456789abc", 13, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcd), "+123456789abcd", 14, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcde), "+123456789abcde", 15, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcdef), "+123456789abcdef", 16, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcdef0), "+123456789abcdef0", 17, hex, Eof);
+
+ TEST (T, +LL ( 0x0), "+0x0", 4, hex, Eof);
+ TEST (T, +LL ( 0x1), "+0x1", 4, hex, Eof);
+ TEST (T, +LL ( 0x12), "+0x12", 5, hex, Eof);
+ TEST (T, +LL ( 0x123), "+0x123", 6, hex, Eof);
+ TEST (T, +LL ( 0x1234), "+0x1234", 7, hex, Eof);
+ TEST (T, +LL ( 0x12345), "+0x12345", 8, hex, Eof);
+ TEST (T, +LL ( 0x123456), "+0x123456", 9, hex, Eof);
+ TEST (T, +LL ( 0x1234567), "+0x1234567", 10, hex, Eof);
+ TEST (T, +LL ( 0x12345678), "+0x12345678", 11, hex, Eof);
+ TEST (T, +LL ( 0x123456789), "+0x123456789", 12, hex, Eof);
+ TEST (T, +LL ( 0x123456789a), "+0x123456789a", 13, hex, Eof);
+ TEST (T, +LL ( 0x123456789ab), "+0x123456789ab", 14, hex, Eof);
+ TEST (T, +LL ( 0x123456789abc), "+0x123456789abc", 15, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcd), "+0x123456789abcd", 16, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcde), "+0x123456789abcde", 17, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcdef), "+0x123456789abcdef", 18, hex, Eof);
+ TEST (T, +LL ( 0x123456789abcdef0), "+0x123456789abcdef0", 19, hex, Eof);
+
+ TEST (T, +LL ( 0x0), "+00000000000000000000", 21, hex, Eof);
+ TEST (T, +LL ( 0x1), "+0000000000000000001", 20, hex, Eof);
+ TEST (T, +LL ( 0x2), "+000000000000000002", 19, hex, Eof);
+ TEST (T, +LL ( 0x3), "+00000000000000003", 18, hex, Eof);
+ TEST (T, +LL ( 0x4), "+0000000000000004", 17, hex, Eof);
+ TEST (T, +LL ( 0x5), "+000000000000005", 16, hex, Eof);
+ TEST (T, +LL ( 0x6), "+00000000000006", 15, hex, Eof);
+ TEST (T, +LL ( 0x7), "+0000000000007", 14, hex, Eof);
+ TEST (T, +LL ( 0x8), "+000000000008", 13, hex, Eof);
+ TEST (T, +LL ( 0x9), "+00000000009", 12, hex, Eof);
+ TEST (T, +LL ( 0xa), "+000000000a", 11, hex, Eof);
+ TEST (T, +LL ( 0xb), "+00000000b", 10, hex, Eof);
+ TEST (T, +LL ( 0xc), "+0000000c", 9, hex, Eof);
+ TEST (T, +LL ( 0xd), "+000000d", 8, hex, Eof);
+ TEST (T, +LL ( 0xe), "+00000e", 7, hex, Eof);
+ TEST (T, +LL ( 0xf), "+0000f", 6, hex, Eof);
+ TEST (T, +LL ( 0x1), "+0001", 5, hex, Eof);
+ TEST (T, +LL ( 0x2), "+002", 4, hex, Eof);
+ TEST (T, +LL ( 0x3), "+03", 3, hex, Eof);
+ TEST (T, +LL ( 0x4), "+4", 2, hex, Eof);
+
+ TEST (T, -LL ( 0x0), "-0", 2, hex, Eof);
+ TEST (T, -LL ( 0x1), "-1", 2, hex, Eof);
+ TEST (T, -LL ( 0x12), "-12", 3, hex, Eof);
+ TEST (T, -LL ( 0x123), "-123", 4, hex, Eof);
+ TEST (T, -LL ( 0x1234), "-1234", 5, hex, Eof);
+ TEST (T, -LL ( 0x12345), "-12345", 6, hex, Eof);
+ TEST (T, -LL ( 0x123456), "-123456", 7, hex, Eof);
+ TEST (T, -LL ( 0x1234567), "-1234567", 8, hex, Eof);
+ TEST (T, -LL ( 0x12345678), "-12345678", 9, hex, Eof);
+ TEST (T, -LL ( 0x123456789), "-123456789", 10, hex, Eof);
+ TEST (T, -LL ( 0x123456789a), "-123456789a", 11, hex, Eof);
+ TEST (T, -LL ( 0x123456789ab), "-123456789ab", 12, hex, Eof);
+ TEST (T, -LL ( 0x123456789abc), "-123456789abc", 13, hex, Eof);
+ TEST (T, -LL ( 0x123456789abcd), "-123456789abcd", 14, hex, Eof);
+ TEST (T, -LL ( 0x123456789abcde), "-123456789abcde", 15, hex, Eof);
+ TEST (T, -LL ( 0x123456789abcdef), "-123456789abcdef", 16, hex, Eof);
+ TEST (T, -LL ( 0x123456789abcdef0), "-123456789abcdef0", 17, hex, Eof);
+
+ TEST (T, -LL ( 0x0), "-00000000000000000000", 21, hex, Eof);
+ TEST (T, -LL ( 0x1), "-0000000000000000001", 20, hex, Eof);
+ TEST (T, -LL ( 0x2), "-000000000000000002", 19, hex, Eof);
+ TEST (T, -LL ( 0x3), "-00000000000000003", 18, hex, Eof);
+ TEST (T, -LL ( 0x4), "-0000000000000004", 17, hex, Eof);
+ TEST (T, -LL ( 0x5), "-000000000000005", 16, hex, Eof);
+ TEST (T, -LL ( 0x6), "-00000000000006", 15, hex, Eof);
+ TEST (T, -LL ( 0x7), "-0000000000007", 14, hex, Eof);
+ TEST (T, -LL ( 0x8), "-000000000008", 13, hex, Eof);
+ TEST (T, -LL ( 0x9), "-00000000009", 12, hex, Eof);
+ TEST (T, -LL ( 0xa), "-000000000a", 11, hex, Eof);
+ TEST (T, -LL ( 0xb), "-00000000b", 10, hex, Eof);
+ TEST (T, -LL ( 0xc), "-0000000c", 9, hex, Eof);
+ TEST (T, -LL ( 0xd), "-000000d", 8, hex, Eof);
+ TEST (T, -LL ( 0xe), "-00000e", 7, hex, Eof);
+ TEST (T, -LL ( 0xf), "-0000f", 6, hex, Eof);
+ TEST (T, -LL ( 0x1), "-0001", 5, hex, Eof);
+ TEST (T, -LL ( 0x2), "-002", 4, hex, Eof);
+ TEST (T, -LL ( 0x3), "-03", 3, hex, Eof);
+ TEST (T, -LL ( 0x4), "-4", 2, hex, Eof);
+
if (rw_opt_no_errno) {
rw_note (0, 0, 0, "errno test disabled");
}
@@ -1622,12 +1920,151 @@
# define ULL(number) number ## UI64
# endif // _MSC_VER
- TEST (T, ULL ( 0), "0", 1, 0, Eof);
- TEST (T, ULL ( 0), "+0", 2, 0, Eof);
- TEST (T, ULL ( 0), "-0", 2, 0, Eof);
- TEST (T, ULL ( 1), "+1", 2, 0, Eof);
- TEST (T, ULL ( 1080), "1080", 4, 0, Eof);
- TEST (T, ULL (18446744073709551615), "18446744073709551615", 20, 0, Eof);
+ TEST (T, ULL ( 0), "0", 1, 0, Eof);
+ TEST (T, ULL ( 1), "1", 1, 0, Eof);
+ TEST (T, ULL ( 12), "12", 2, 0, Eof);
+ TEST (T, ULL ( 123), "123", 3, 0, Eof);
+ TEST (T, ULL ( 1234), "1234", 4, 0, Eof);
+ TEST (T, ULL ( 12345), "12345", 5, 0, Eof);
+ TEST (T, ULL ( 123456), "123456", 6, 0, Eof);
+ TEST (T, ULL ( 1234567), "1234567", 7, 0, Eof);
+ TEST (T, ULL ( 12345678), "12345678", 8, 0, Eof);
+ TEST (T, ULL ( 123456789), "123456789", 9, 0, Eof);
+ TEST (T, ULL ( 1234567890), "1234567890", 10, 0, Eof);
+ TEST (T, ULL ( 12345678901), "12345678901", 11, 0, Eof);
+ TEST (T, ULL ( 123456789012), "123456789012", 12, 0, Eof);
+ TEST (T, ULL ( 1234567890123), "1234567890123", 13, 0, Eof);
+ TEST (T, ULL ( 12345678901234), "12345678901234", 14, 0, Eof);
+ TEST (T, ULL ( 123456789012345), "123456789012345", 15, 0, Eof);
+ TEST (T, ULL ( 1234567890123456), "1234567890123456", 16, 0, Eof);
+ TEST (T, ULL ( 12345678901234567), "12345678901234567", 17, 0, Eof);
+ TEST (T, ULL ( 123456789012345678), "123456789012345678", 18, 0, Eof);
+ TEST (T, ULL ( 1234567890123456789), "1234567890123456789", 19, 0, Eof);
+
+ TEST (T, ULL ( 0), "0000000000000000000", 19, dec, Eof);
+ TEST (T, ULL ( 1), "0000000000000000001", 19, dec, Eof);
+ TEST (T, ULL ( 2), "000000000000000002", 18, dec, Eof);
+ TEST (T, ULL ( 3), "00000000000000003", 17, dec, Eof);
+ TEST (T, ULL ( 4), "0000000000000004", 16, dec, Eof);
+ TEST (T, ULL ( 5), "000000000000005", 15, dec, Eof);
+ TEST (T, ULL ( 6), "00000000000006", 14, dec, Eof);
+ TEST (T, ULL ( 7), "0000000000007", 13, dec, Eof);
+ TEST (T, ULL ( 8), "000000000008", 12, dec, Eof);
+ TEST (T, ULL ( 9), "00000000009", 11, dec, Eof);
+ TEST (T, ULL ( 1), "0000000001", 10, dec, Eof);
+ TEST (T, ULL ( 2), "000000002", 9, dec, Eof);
+ TEST (T, ULL ( 3), "00000003", 8, dec, Eof);
+ TEST (T, ULL ( 4), "0000004", 7, dec, Eof);
+ TEST (T, ULL ( 5), "000005", 6, dec, Eof);
+ TEST (T, ULL ( 6), "00006", 5, dec, Eof);
+ TEST (T, ULL ( 7), "0007", 4, dec, Eof);
+ TEST (T, ULL ( 8), "008", 3, dec, Eof);
+ TEST (T, ULL ( 9), "09", 2, dec, Eof);
+
+ TEST (T, ULL ( 0), "+0", 2, 0, Eof);
+ TEST (T, ULL ( 1), "+1", 2, 0, Eof);
+ TEST (T, ULL ( 12), "+12", 3, 0, Eof);
+ TEST (T, ULL ( 123), "+123", 4, 0, Eof);
+ TEST (T, ULL ( 1234), "+1234", 5, 0, Eof);
+ TEST (T, ULL ( 12345), "+12345", 6, 0, Eof);
+ TEST (T, ULL ( 123456), "+123456", 7, 0, Eof);
+ TEST (T, ULL ( 1234567), "+1234567", 8, 0, Eof);
+ TEST (T, ULL ( 12345678), "+12345678", 9, 0, Eof);
+ TEST (T, ULL ( 123456789), "+123456789", 10, 0, Eof);
+ TEST (T, ULL ( 1234567890), "+1234567890", 11, 0, Eof);
+ TEST (T, ULL ( 12345678901), "+12345678901", 12, 0, Eof);
+ TEST (T, ULL ( 123456789012), "+123456789012", 13, 0, Eof);
+ TEST (T, ULL ( 1234567890123), "+1234567890123", 14, 0, Eof);
+ TEST (T, ULL ( 12345678901234), "+12345678901234", 15, 0, Eof);
+ TEST (T, ULL ( 123456789012345), "+123456789012345", 16, 0, Eof);
+ TEST (T, ULL ( 1234567890123456), "+1234567890123456", 17, 0, Eof);
+ TEST (T, ULL ( 12345678901234567), "+12345678901234567", 18, 0, Eof);
+ TEST (T, ULL ( 123456789012345678), "+123456789012345678", 19, 0, Eof);
+ TEST (T, ULL ( 1234567890123456789), "+1234567890123456789", 20, 0, Eof);
+
+ TEST (T, ULL ( 0), "+0000000000000000000", 20, dec, Eof);
+ TEST (T, ULL ( 1), "+0000000000000000001", 20, dec, Eof);
+ TEST (T, ULL ( 2), "+000000000000000002", 19, dec, Eof);
+ TEST (T, ULL ( 3), "+00000000000000003", 18, dec, Eof);
+ TEST (T, ULL ( 4), "+0000000000000004", 17, dec, Eof);
+ TEST (T, ULL ( 5), "+000000000000005", 16, dec, Eof);
+ TEST (T, ULL ( 6), "+00000000000006", 15, dec, Eof);
+ TEST (T, ULL ( 7), "+0000000000007", 14, dec, Eof);
+ TEST (T, ULL ( 8), "+000000000008", 13, dec, Eof);
+ TEST (T, ULL ( 9), "+00000000009", 12, dec, Eof);
+ TEST (T, ULL ( 1), "+0000000001", 11, dec, Eof);
+ TEST (T, ULL ( 2), "+000000002", 10, dec, Eof);
+ TEST (T, ULL ( 3), "+00000003", 9, dec, Eof);
+ TEST (T, ULL ( 4), "+0000004", 8, dec, Eof);
+ TEST (T, ULL ( 5), "+000005", 7, dec, Eof);
+ TEST (T, ULL ( 6), "+00006", 6, dec, Eof);
+ TEST (T, ULL ( 7), "+0007", 5, dec, Eof);
+ TEST (T, ULL ( 8), "+008", 4, dec, Eof);
+ TEST (T, ULL ( 9), "+09", 3, dec, Eof);
+
+ TEST (T, ULL ( 0), "-0", 2, 0, Eof);
+ TEST (T, ULL (18446744073709551615), "-1", 2, 0, Eof);
+ TEST (T, ULL (18446744073709551604), "-12", 3, 0, Eof);
+ TEST (T, ULL (18446744073709551493), "-123", 4, 0, Eof);
+ TEST (T, ULL (18446744073709550382), "-1234", 5, 0, Eof);
+ TEST (T, ULL (18446744073709539271), "-12345", 6, 0, Eof);
+ TEST (T, ULL (18446744073709428160), "-123456", 7, 0, Eof);
+ TEST (T, ULL (18446744073708317049), "-1234567", 8, 0, Eof);
+ TEST (T, ULL (18446744073697205938), "-12345678", 9, 0, Eof);
+ TEST (T, ULL (18446744073586094827), "-123456789", 10, 0, Eof);
+ TEST (T, ULL (18446744072474983726), "-1234567890", 11, 0, Eof);
+ TEST (T, ULL (18446744061363872715), "-12345678901", 12, 0, Eof);
+ TEST (T, ULL (18446743950252762604), "-123456789012", 13, 0, Eof);
+ TEST (T, ULL (18446742839141661493), "-1234567890123", 14, 0, Eof);
+ TEST (T, ULL (18446731728030650382), "-12345678901234", 15, 0, Eof);
+ TEST (T, ULL (18446620616920539271), "-123456789012345", 16, 0, Eof);
+ TEST (T, ULL (18445509505819428160), "-1234567890123456", 17, 0, Eof);
+ TEST (T, ULL (18434398394808317049), "-12345678901234567", 18, 0, Eof);
+ TEST (T, ULL (18323287284697205938), "-123456789012345678", 19, 0, Eof);
+ TEST (T, ULL (17212176183586094827), "-1234567890123456789", 20, 0, Eof);
+
+ TEST (T, ULL ( 0), "-0000000000000000000", 20, dec, Eof);
+ TEST (T, ULL (18446744073709551615), "-0000000000000000001", 20, dec, Eof);
+ TEST (T, ULL (18446744073709551614), "-000000000000000002", 19, dec, Eof);
+ TEST (T, ULL (18446744073709551613), "-00000000000000003", 18, dec, Eof);
+ TEST (T, ULL (18446744073709551612), "-0000000000000004", 17, dec, Eof);
+ TEST (T, ULL (18446744073709551611), "-000000000000005", 16, dec, Eof);
+ TEST (T, ULL (18446744073709551610), "-00000000000006", 15, dec, Eof);
+ TEST (T, ULL (18446744073709551609), "-0000000000007", 14, dec, Eof);
+ TEST (T, ULL (18446744073709551608), "-000000000008", 13, dec, Eof);
+ TEST (T, ULL (18446744073709551607), "-00000000009", 12, dec, Eof);
+ TEST (T, ULL (18446744073709551615), "-0000000001", 11, dec, Eof);
+ TEST (T, ULL (18446744073709551614), "-000000002", 10, dec, Eof);
+ TEST (T, ULL (18446744073709551613), "-00000003", 9, dec, Eof);
+ TEST (T, ULL (18446744073709551612), "-0000004", 8, dec, Eof);
+ TEST (T, ULL (18446744073709551611), "-000005", 7, dec, Eof);
+ TEST (T, ULL (18446744073709551610), "-00006", 6, dec, Eof);
+ TEST (T, ULL (18446744073709551609), "-0007", 5, dec, Eof);
+ TEST (T, ULL (18446744073709551608), "-008", 4, dec, Eof);
+ TEST (T, ULL (18446744073709551607), "-09", 3, dec, Eof);
+
+ TEST (T, ULL (18446744073709551615), "18446744073709551615", 20, 0, Eof);
+ TEST (T, ULL (18446744073709551615), "018446744073709551615", 21, dec, Eof);
+ TEST (T, ULL (18446744073709551615), "+18446744073709551615", 21, 0, Eof);
+
+ // exercise hex parsing
+ TEST (T, ULL ( 0x0), "0x0", 3, hex, Eof);
+ TEST (T, ULL ( 0x1), "0x1", 3, hex, Eof);
+ TEST (T, ULL ( 0x12), "0x12", 4, hex, Eof);
+ TEST (T, ULL ( 0x123), "0x123", 5, hex, Eof);
+ TEST (T, ULL ( 0x1234), "0x1234", 6, hex, Eof);
+ TEST (T, ULL ( 0x12345), "0x12345", 7, hex, Eof);
+ TEST (T, ULL ( 0x123456), "0x123456", 8, hex, Eof);
+ TEST (T, ULL ( 0x1234567), "0x1234567", 9, hex, Eof);
+ TEST (T, ULL ( 0x12345678), "0x12345678", 10, hex, Eof);
+ TEST (T, ULL ( 0x123456789), "0x123456789", 11, hex, Eof);
+ TEST (T, ULL ( 0x123456789a), "0x123456789a", 12, hex, Eof);
+ TEST (T, ULL ( 0x123456789ab), "0x123456789ab", 13, hex, Eof);
+ TEST (T, ULL ( 0x123456789abc), "0x123456789abc", 14, hex, Eof);
+ TEST (T, ULL ( 0x123456789abcd), "0x123456789abcd", 15, hex, Eof);
+ TEST (T, ULL ( 0x123456789abcde), "0x123456789abcde", 16, hex, Eof);
+ TEST (T, ULL ( 0x123456789abcdef), "0x123456789abcdef", 17, hex, Eof);
+ TEST (T, ULL ( 0x123456789abcdef0), "0x123456789abcdef0", 18, hex, Eof);
if (rw_opt_no_errno) {
rw_note (0, 0, 0, "errno test disabled");
@@ -1943,7 +2380,7 @@
if (test_locale) {
// verify that the global LC_NUMERIC locale setting
// has no impact on the facet (in case it uses scanf())
- for (const char *name = rw_locales (LC_NUMERIC, 0); *name;
+ for (const char *name = rw_locales (LC_NUMERIC, 0); name && *name;
name += std::strlen (name) + 1) {
// find the first locale whose decimal_point character
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.put.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.put.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.put.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.num.put.cpp Tue Jun 26 16:58:07 2007
@@ -1480,7 +1480,7 @@
if (1) {
// verify that the global LC_NUMERIC setting has no impact on the facet
- for (const char *name = rw_locales (LC_NUMERIC, 0); *name;
+ for (const char *name = rw_locales (LC_NUMERIC, 0); name && *name;
name += std::strlen (name) + 1) {
// find the first locale whose decimal_point character
Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.time.get.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.time.get.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.time.get.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.time.get.cpp Tue Jun 26 16:58:07 2007
@@ -1584,7 +1584,9 @@
#else // _WIN{32,64}
// FIXME: handle non-UNIX systems
- for (const char *loc = rw_locales (); *loc; loc += std::strlen (loc) + 1) {
+ for (const char *loc = rw_locales (); loc && *loc;
+ loc += std::strlen (loc) + 1) {
+
if (!std::strcmp (loc, name))
return loc;
}
Modified: incubator/stdcxx/branches/4.2.0/tests/self/0.inputiter.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/self/0.inputiter.cpp?view=diff&rev=550991&r1=550990&r2=550991
==============================================================================
--- incubator/stdcxx/branches/4.2.0/tests/self/0.inputiter.cpp (original)
+++ incubator/stdcxx/branches/4.2.0/tests/self/0.inputiter.cpp Tue Jun 26 16:58:07 2007
@@ -30,6 +30,10 @@
#include <signal.h>
#include <stdio.h>
+#ifdef _MSC_VER
+#include <crtdbg.h> // for _CrtSetReportMode()
+#endif
+
#include <alg_test.h> // for InputIter
#include <rw_value.h> // for UserClass
#include <driver.h> // for rw_test(), ...
@@ -353,6 +357,11 @@
int main (int argc, char *argv[])
{
+#ifdef _MSC_VER
+ // disable GUI window from abort()
+ _CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_DEBUG);
+#endif
+
return rw_test (argc, argv, __FILE__,
0 /* no clause */,
0 /* no comment */, run_test,