components/stdcxx/patches/062-stdcxx-866-22.locale.num.get.cpp.patch
changeset 402 94ae4d75524c
equal deleted inserted replaced
401:bf52ef48020c 402:94ae4d75524c
       
     1 --- stdcxx-4.2.1/tests/localization/22.locale.num.get.cpp	2008-04-24 17:23:10.000000000 -0700
       
     2 +++ stdcxx-4.2.1/tests/localization/22.locale.num.get.cpp	2011-03-24 08:39:22.961646495 -0700
       
     3 @@ -54,6 +54,10 @@
       
     4  #  define NO_GET_LDBL
       
     5  #endif   // NO_GET_FLOATING
       
     6  
       
     7 +#ifndef _STDCXX_SIZEOF_NUM_GET_BUFFER
       
     8 +#define _STDCXX_SIZEOF_NUM_GET_BUFFER 16384
       
     9 +#endif
       
    10 +
       
    11  /**************************************************************************/
       
    12  
       
    13  #include <cstddef>   // for std::size_t, std::ptrdiff_t
       
    14 @@ -235,6 +239,13 @@
       
    15  
       
    16  /**************************************************************************/
       
    17  
       
    18 +// if non-zero expected to point to a maximum valid value
       
    19 +// of type T that's being tested below (used for floating
       
    20 +// point ranges)
       
    21 +// on function return, the pointed to value is overwritten
       
    22 +// with the actual extracted value
       
    23 +void *pmax = 0;
       
    24 +
       
    25  
       
    26  enum IterType { iter_pointer, iter_istreambuf, iter_input };
       
    27  
       
    28 @@ -244,7 +255,6 @@
       
    29               const char *cname,           // name of character type
       
    30               IterType    itype,           // type of input iterator
       
    31               const char *iname,           // name of input iterator
       
    32 -             void       *pmax,
       
    33               nativeT     val,             // value expected to be extracted
       
    34               const char *str,             // input sequence
       
    35               int         eat_expect = -1, // number of consumed characters
       
    36 @@ -438,7 +448,6 @@
       
    37               const char *cname,           // name of character type
       
    38               IterType    itype,           // iterator type
       
    39               const char *iname,           // name of iterator type
       
    40 -             void       *pmax,
       
    41               nativeT     val,             // value expected to be extracted
       
    42               const char *str,             // input sequence
       
    43               int         eat_expect = -1, // number of consumed characters
       
    44 @@ -449,15 +458,15 @@
       
    45      switch (ctype) {
       
    46      case narrow_char:
       
    47          return do_test (lineno, (char*)0, cname, itype, iname,
       
    48 -                        pmax, val, str, eat_expect, flags, err_expect, grouping);
       
    49 +                        val, str, eat_expect, flags, err_expect, grouping);
       
    50      case wide_char:
       
    51          return do_test (lineno, (wchar_t*)0, cname, itype, iname,
       
    52 -                        pmax, val, str, eat_expect, flags, err_expect, grouping);
       
    53 +                        val, str, eat_expect, flags, err_expect, grouping);
       
    54      case user_char:
       
    55          break;
       
    56  #if 0   // disabled
       
    57          return do_test (lineno, (UserChar*)0, cname, itype, iname,
       
    58 -                        pmax, val, str, eat_expect, flags, err_expect, grouping);
       
    59 +                        val, str, eat_expect, flags, err_expect, grouping);
       
    60  #endif   // disabled
       
    61      }
       
    62  
       
    63 @@ -497,8 +506,7 @@
       
    64  /*************************************************************************/
       
    65  
       
    66  #define TEST   do_test
       
    67 -#define T      __LINE__, ctype, cname, itype, iname, 0
       
    68 -#define T_MAX  __LINE__, ctype, cname, itype, iname, &val
       
    69 +#define T      __LINE__, ctype, cname, itype, iname
       
    70  
       
    71  
       
    72  template <class numT>
       
    73 @@ -2441,7 +2449,8 @@
       
    74               cname, iname);
       
    75  
       
    76      // exercise bahvior on underflow
       
    77 -    float val = 0;
       
    78 +    static float val = 0;
       
    79 +    pmax = &val;
       
    80  
       
    81      // on underflow, get() follows C99 requirements on strtof()
       
    82      // i.e., it stores a value in the range [0, +/-FLT_MIN]
       
    83 @@ -2452,34 +2461,35 @@
       
    84      //     normalized positive number in the return type; whether
       
    85      //     errno acquires the value ERANGE is implementation-defined.
       
    86  
       
    87 -    TEST (T_MAX, (val = FLT_MIN, 0.0f), "1.111111e-9999", 14, 0, Eof);
       
    88 +    TEST (T, (val = FLT_MIN, 0.0f), "1.111111e-9999", 14, 0, Eof);
       
    89      rw_assert (!(val < 0.0), 0, __LINE__,
       
    90                 "correct sign after positive underflow");
       
    91  
       
    92 -    TEST (T_MAX, (val = 0.0f, -FLT_MIN), "-1.111111e-9999", 15, 0, Eof);
       
    93 +    TEST (T, (val = 0.0f, -FLT_MIN), "-1.111111e-9999", 15, 0, Eof);
       
    94      rw_assert (!(val > 0.0), 0, __LINE__,
       
    95                 "correct sign after negative underflow");
       
    96  
       
    97      if (1.234567e-39 < FLT_MIN) {
       
    98 -        TEST (T_MAX, (val = FLT_MIN, 0.0f),   "1.234567e-39", 12, 0, Eof);
       
    99 -        TEST (T_MAX, (val = 0.0f, -FLT_MIN), "-1.234567e-39", 13, 0, Eof);
       
   100 +        TEST (T, (val = FLT_MIN, 0.0f),   "1.234567e-39", 12, 0, Eof);
       
   101 +        TEST (T, (val = 0.0f, -FLT_MIN), "-1.234567e-39", 13, 0, Eof);
       
   102      }
       
   103  
       
   104      if (1.234567e-49 < FLT_MIN) {
       
   105 -        TEST (T_MAX, (val = FLT_MIN, 0.0f),   "1.234567e-49", 12, 0, Eof);
       
   106 -        TEST (T_MAX, (val = 0.0f, -FLT_MIN), "-1.234567e-49", 13, 0, Eof);
       
   107 +        TEST (T, (val = FLT_MIN, 0.0f),   "1.234567e-49", 12, 0, Eof);
       
   108 +        TEST (T, (val = 0.0f, -FLT_MIN), "-1.234567e-49", 13, 0, Eof);
       
   109      }
       
   110  
       
   111      if (1.234567e-99 < FLT_MIN) {
       
   112 -        TEST (T_MAX, (val = FLT_MIN, 0.0f),   "1.234567e-99", 12, 0, Eof);
       
   113 -        TEST (T_MAX, (val = 0.0f, -FLT_MIN), "-1.234567e-99", 13, 0, Eof);
       
   114 +        TEST (T, (val = FLT_MIN, 0.0f),   "1.234567e-99", 12, 0, Eof);
       
   115 +        TEST (T, (val = 0.0f, -FLT_MIN), "-1.234567e-99", 13, 0, Eof);
       
   116      }
       
   117  
       
   118      // exercise facet's behavior on underflow:
       
   119      //   parsing succeeds (fail is clear), +/-min is stored
       
   120 -    TEST (T_MAX,  FLT_MIN, _RWSTD_STRSTR ( _RWSTD_DBL_MIN), -1, 0, Eof);
       
   121 -    TEST (T_MAX, -FLT_MIN, _RWSTD_STRSTR (-_RWSTD_DBL_MIN), -1, 0, Eof);
       
   122 +    TEST (T,  FLT_MIN, _RWSTD_STRSTR ( _RWSTD_DBL_MIN), -1, 0, Eof);
       
   123 +    TEST (T, -FLT_MIN, _RWSTD_STRSTR (-_RWSTD_DBL_MIN), -1, 0, Eof);
       
   124  
       
   125 +    pmax = 0;   // reset before next test
       
   126  
       
   127  
       
   128      rw_info (0, 0, 0, "std::num_get<%s, %s>::get (..., float&) on overflow",
       
   129 @@ -2610,7 +2620,8 @@
       
   130               cname, iname);
       
   131  
       
   132      // exercise bahvior on underflow
       
   133 -    double val = DBL_MIN;
       
   134 +    static double val = DBL_MIN;
       
   135 +    pmax = &val;
       
   136  
       
   137      // on underflow, get() follows C99 requirements on strtod()
       
   138      // i.e., it stores a value in the range [0, +/-DBL_MIN]
       
   139 @@ -2621,24 +2632,25 @@
       
   140      //     normalized positive number in the return type; whether
       
   141      //     errno acquires the value ERANGE is implementation-defined.
       
   142  
       
   143 -    TEST (T_MAX, (val = DBL_MIN, 0.0),   "1.111111e-9999", 14, 0, Eof);
       
   144 -    TEST (T_MAX, (val = 0.0, -DBL_MIN), "-1.111111e-9999", 15, 0, Eof);
       
   145 +    TEST (T, (val = DBL_MIN, 0.0),   "1.111111e-9999", 14, 0, Eof);
       
   146 +    TEST (T, (val = 0.0, -DBL_MIN), "-1.111111e-9999", 15, 0, Eof);
       
   147  
       
   148      if (1.23456789e-309L < DBL_MIN) {
       
   149 -        TEST (T_MAX, (val = DBL_MIN, 0.0),   "1.23456789e-309", 15, 0, Eof);
       
   150 -        TEST (T_MAX, (val = 0.0, -DBL_MIN), "-1.23456789e-309", 16, 0, Eof);
       
   151 +        TEST (T, (val = DBL_MIN, 0.0),   "1.23456789e-309", 15, 0, Eof);
       
   152 +        TEST (T, (val = 0.0, -DBL_MIN), "-1.23456789e-309", 16, 0, Eof);
       
   153      }
       
   154  
       
   155      if (1.234567e-409L < DBL_MIN) {
       
   156 -        TEST (T_MAX, (val = DBL_MIN, 0.0),   "1.23456789e-409", 15, 0, Eof);
       
   157 -        TEST (T_MAX, (val = 0.0, -DBL_MIN), "-1.23456789e-409", 16, 0, Eof);
       
   158 +        TEST (T, (val = DBL_MIN, 0.0),   "1.23456789e-409", 15, 0, Eof);
       
   159 +        TEST (T, (val = 0.0, -DBL_MIN), "-1.23456789e-409", 16, 0, Eof);
       
   160      }
       
   161  
       
   162      if (1.234567e-999L < DBL_MIN) {
       
   163 -        TEST (T_MAX, (val = DBL_MIN, 0.0),   "1.23456789e-999", 15, 0, Eof);
       
   164 -        TEST (T_MAX, (val = 0.0, -DBL_MIN), "-1.23456789e-999", 16, 0, Eof);
       
   165 +        TEST (T, (val = DBL_MIN, 0.0),   "1.23456789e-999", 15, 0, Eof);
       
   166 +        TEST (T, (val = 0.0, -DBL_MIN), "-1.23456789e-999", 16, 0, Eof);
       
   167      }
       
   168  
       
   169 +    pmax = 0;   // reset before next test
       
   170  
       
   171  
       
   172  #  ifdef _RWSTD_LDBL_MAX
       
   173 @@ -2731,7 +2743,8 @@
       
   174               cname, iname);
       
   175  
       
   176      // exercise bahvior on underflow
       
   177 -    long double val = LDBL_MIN;
       
   178 +    static long double val = LDBL_MIN;
       
   179 +    pmax = &val;
       
   180  
       
   181      // on underflow, get() follows C99 requirements on strtold()
       
   182      // i.e., it stores a value in the range [0, +/-LDBL__MIN]
       
   183 @@ -2742,22 +2755,23 @@
       
   184      //     normalized positive number in the return type; whether
       
   185      //     errno acquires the value ERANGE is implementation-defined.
       
   186  
       
   187 -    TEST (T_MAX, (val = LDBL_MIN, 0.0L),   "1.987654321e-99999", 18, 0, Eof);
       
   188 -    TEST (T_MAX, (val = 0.0L, -LDBL_MIN), "-1.987654321e-99999", 19, 0, Eof);
       
   189 +    TEST (T, (val = LDBL_MIN, 0.0L),   "1.987654321e-99999", 18, 0, Eof);
       
   190 +    TEST (T, (val = 0.0L, -LDBL_MIN), "-1.987654321e-99999", 19, 0, Eof);
       
   191  
       
   192      const char fmt[] = "%Lg";
       
   193  
       
   194      long double ld = 0.0;
       
   195      if (1 == std::sscanf ("3.456789e-4932", fmt, &ld) && ld < LDBL_MIN) {
       
   196 -        TEST (T_MAX, (val = LDBL_MIN, 0.0L),   "3.456789e-4932", 14, 0, Eof);
       
   197 -        TEST (T_MAX, (val = 0.0L, -LDBL_MIN), "-3.456789e-4932", 15, 0, Eof);
       
   198 +        TEST (T, (val = LDBL_MIN, 0.0L),   "3.456789e-4932", 14, 0, Eof);
       
   199 +        TEST (T, (val = 0.0L, -LDBL_MIN), "-3.456789e-4932", 15, 0, Eof);
       
   200      }
       
   201  
       
   202      if (1 == std::sscanf ("3.456789e-9999", fmt, &ld) && ld < LDBL_MIN) {
       
   203 -        TEST (T_MAX, (val = LDBL_MIN, 0.0L),   "3.456789e-9999", 14, 0, Eof);
       
   204 -        TEST (T_MAX, (val = 0.0L, -LDBL_MIN), "-3.456789e-9999", 15, 0, Eof);
       
   205 +        TEST (T, (val = LDBL_MIN, 0.0L),   "3.456789e-9999", 14, 0, Eof);
       
   206 +        TEST (T, (val = 0.0L, -LDBL_MIN), "-3.456789e-9999", 15, 0, Eof);
       
   207      }
       
   208  
       
   209 +    pmax = 0;   // reset before next test
       
   210  
       
   211  
       
   212  #  ifdef _RWSTD_LDBL_MAX