42 static T (
min) () {
return 0; }
43 static T (
max) () {
return 0; }
68 T max_plus_one = _max;
70 return ++max_plus_one < _max;
104#ifndef _RWSTD_NO_BOOL
152 return std::sprintf (
buf,
"%d", (
unsigned char)
CHAR_MAX) - 1;
177 return std::sprintf (
buf,
"%d", (
unsigned char)
SCHAR_MAX) - 1;
186 static unsigned char (
min) () {
return 0; }
202 return std::sprintf (
buf,
"%d", (
unsigned char)
UCHAR_MAX) - 1;
206#ifndef _RWSTD_NO_NATIVE_WCHAR_T
249 return std::sprintf (
buf,
"%u",
wchar_t (~0)) - 1;
275 return std::sprintf (
buf,
"%d", (
int)
SHRT_MAX) - 1;
309 static unsigned short (
min) () {
return 0; }
324 return std::sprintf (
buf,
"%u",
unsigned (
USHRT_MAX)) - 1;
333 static unsigned int (
min) () {
return 0; }
358 static unsigned long (
min) () {
return 0; }
378#ifdef _RWSTD_LONG_LONG
395 return ~ULLong (0) /
ULLong (2);
406 static bool is_modulo () { return ::is_modulo ((
max)()); }
410 const char fmt[] =
"%" _RWSTD_LLONG_PRINTF_PREFIX
"u";
411 return std::sprintf (
buf, fmt, (
max) ()) - 1;
424 static ULLong (
max) () {
return ~ULLong (0); }
434 static bool is_modulo () { return ::is_modulo ((
max)()); }
438 const char fmt[] =
"%" _RWSTD_LLONG_PRINTF_PREFIX
"i";
441 const int n = std::sprintf (
buf, fmt, (
max) ());
456 typedef std::numeric_limits<T> limT;
462#if !defined (__EDG__) || __EDG_VERSION__ > 245
464# define ASSERT(expr, fmt) \
466 { enum { is_const_integral_expression = limT::expr }; } \
467 rw_assert (limT::expr == int (Traits::expr), 0, __LINE__, \
468 "std::numeric_limits<%s>::" #expr \
469 " == %{@}, got %{@}", \
470 tname, fmt, Traits::expr, fmt, limT::expr)
474# define ASSERT(expr) \
476 switch (limT::expr) { case limT::expr: break; }; \
477 rw_assert (limT::expr == int (Traits::expr), 0, __LINE__, \
478 "std::numeric_limits<%s>::" #expr \
479 "== %{@}, got %{@}", \
480 tname, fmt, Traits::expr, fmt, limT::expr)
483#define ASSERT_0(expr, fmt) \
484 rw_assert (!limT::expr, 0, __LINE__, \
485 "std::numeric_limits<%s>::" #expr " == 0, got %{@}", \
486 tname, fmt, limT::expr)
491 rw_assert ((limT::min)() == (Traits::min)(), 0, __LINE__,
492 "std::numeric_limits<%s>::min() == %{@}, got %{@}",
493 tname, fmt, (Traits::min)(), fmt, (limT::min)());
496 rw_assert ((limT::max)() == (Traits::max)(), 0, __LINE__,
497 "std::numeric_limits<%s>::max() == %{@}, got %{@}",
498 tname, fmt, (Traits::max)(), fmt, (limT::max)());
506 rw_assert (limT::digits10 == Traits::compute_digits10 (), 0, __LINE__,
507 "std::numeric_limits<%s>::digits10 == %d (computed), got %d",
508 tname, Traits::compute_digits10 (), limT::digits10);
574 rw_assert (limT::is_modulo == Traits::is_modulo (), 0, __LINE__,
575 "std::numeric_limits<%s>::is_modulo == %#b",
576 tname, Traits::is_modulo ());
588 rw_assert (limT::round_style ==
int (std::round_toward_zero), 0, __LINE__,
589 "std::numeric_limits<%s>::round_style == %d",
590 tname, std::round_toward_zero);
597#define TEST(T, fmt) run_test ((T*)0, #T, fmt)
600#ifndef _RWSTD_NO_BOOL
607 TEST (
char,
"%{#c}");
608 TEST (
signed char,
"%{#c}");
609 TEST (
unsigned char,
"%{#c}");
612 TEST (
unsigned short,
"%hu");
615 TEST (
unsigned int,
"%u");
618 TEST (
unsigned long,
"%lu");
620#ifdef _RWSTD_LONG_LONG
627#ifndef _RWSTD_NO_NATIVE_WCHAR_T
629 TEST (
wchar_t,
"%{#lc}");
641int main (
int argc,
char *argv[])
643 return rw_test (argc, argv, __FILE__,
645 "integer specializations",
#define ASSERT_0(expr, fmt)
#define ASSERT(expr, fmt)
void run_test(T *, const char *tname, const char *fmt)
#define _RWSTD_SPECIALIZED_CLASS
#define _RWSTD_SPECIALIZED_FUNCTION
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()
static int compute_digits10()