73#ifndef _RWSTD_NO_EXT_CXX_0X
75#include <ansi/cstdint>
80static int rw_opt_no_macros;
81static int rw_opt_no_types;
82static int rw_opt_no_64_bit;
87static const char*
const
102#ifndef INT_LEAST16_MIN
108#ifndef INT_FAST16_MIN
115#ifndef INT_LEAST32_MIN
121#ifndef INT_FAST32_MIN
128#ifndef INT_LEAST8_MAX
134#ifndef UINT_LEAST8_MAX
146#ifndef UINT_FAST8_MAX
153#ifndef INT_LEAST16_MAX
159#ifndef UINT_LEAST16_MAX
165#ifndef INT_FAST16_MAX
171#ifndef UINT_FAST16_MAX
178#ifndef INT_LEAST32_MAX
184#ifndef UINT_LEAST32_MAX
190#ifndef INT_FAST32_MAX
196#ifndef UINT_FAST32_MAX
256#ifndef SIG_ATOMIC_MIN
262#ifndef SIG_ATOMIC_MAX
272static const char*
const
273missing_optional_macros[] = {
297static const char*
const
298missing_64_bit_macros[] = {
300#ifndef INT_LEAST64_MIN
306#ifndef INT_FAST64_MIN
318#ifndef INT_LEAST64_MAX
324#ifndef UINT_LEAST64_MAX
330#ifndef INT_FAST64_MAX
336#ifndef UINT_FAST64_MAX
347#ifndef _RWSTD_NO_NAMESPACE
351#define DEFINE_TYPE(name) \
356 name (int i = 0): i_ (i) { } \
357 operator int () const volatile { return i_; } \
358 name operator- (int i) const volatile { return i_ - i; } \
359 name operator~ () const volatile { return ~0; } \
360 name operator& (int i) const volatile { return i_ & i; } \
361 bool operator< (int i) const volatile { return i_ < i; } \
493 const char *macro_name = 0,
494 const char *valstr = 0)
496 static volatile intT
zero = intT (0);
497 static volatile intT
one = intT (1);
498 static volatile intT minus_one = intT (
zero -
one);
499 static volatile intT all_bits_set = intT (~
zero);
501 const bool is_signed = minus_one <
zero;
503 const unsigned maxbits =
sizeof (intT) * _RWSTD_CHAR_BIT;
508 intT minimum = is_signed ? minus_one :
one;
511 for (
unsigned i = 0;
i != maxbits; ++
i) {
513 if (all_bits_set & (intT (1) <<
i))
518 maximum = intT (maximum * 2);
519 minimum = intT (maximum * 2);
526 if (
zero < testval) {
528 "%s >= %s", macro_name, valstr);
532 "%s <= %s", macro_name, valstr);
537 "%s >= %s", macro_name, valstr);
551 "%s must be an unsigned type",
type_name);
555 const bool success = exact ? expect == nbits : expect <= nbits;
557 if (64 != expect || !rw_opt_no_64_bit)
559 "%s expected width %{?}exactly%{:}at least%{;} "
560 "%d bits, got %d",
type_name, exact, expect, nbits);
569#define TEST_REQUIRED_TYPE(name, bits, exact) \
571 rw_info (0, 0, __LINE__, "std::%s (required)", # name); \
572 const bool type_defined = \
573 sizeof (test_ ## name) != sizeof (Fallback::name); \
574 rw_assert (type_defined, 0, __LINE__, \
575 "required type %s not defined in namespace " \
578 test_bits (__LINE__, test_ ## name (0), \
579 bits, exact, #name); \
582#define TEST_OPTIONAL_TYPE(name, bits, exact) \
584 rw_info (0, 0, __LINE__, "std::%s (optional)", # name); \
585 const bool type_defined = \
586 sizeof (test_ ## name) != sizeof (Fallback::name); \
587 rw_warn (type_defined, 0, __LINE__, \
588 "optional type %s not defined in namespace " \
591 test_bits (__LINE__, test_ ## name (0), \
592 bits, exact, #name); \
622 if (rw_opt_no_64_bit) {
623 rw_note (0, 0, 0,
"tests of 64-bit types disabled");
641 rw_note (0, 0, 0,
"_RWSTD_NO_NAMESPACE defined, cannot test");
652 rw_assert (
'\0' == missing_macros [
i][0], 0, __LINE__,
653 "required macro %s not defined",
657#define TEST_MACRO(T, macro, bits, exact, valstr) \
658 test_bits (__LINE__, test_ ## T (macro), bits, exact, #T, #macro, valstr)
684#define TEST_MACRO_NO_TYPE(macro, bits, exact, valstr) \
685 test_bits (__LINE__, macro, bits, exact, "", #macro, valstr)
702 for (
unsigned i = 0; missing_optional_macros [
i]; ++
i) {
703 rw_warn (
'\0' == missing_optional_macros [
i][0], 0, __LINE__,
704 "optional macro %s not defined",
705 missing_optional_macros [
i]);
720 if (rw_opt_no_64_bit) {
721 rw_note (0, 0, 0,
"tests of 64-bit macros disabled");
724 for (
unsigned i = 0; missing_64_bit_macros [
i]; ++
i) {
725 rw_assert (
'\0' == missing_64_bit_macros [
i][0], 0, __LINE__,
726 "required macro %s not defined",
727 missing_64_bit_macros [
i]);
758int main (
int argc,
char *argv[])
760 return rw_test (argc, argv, __FILE__,
778 "test disabled because _RWSTD_NO_EXT_CXX_0X is defined");
782int main (
int argc,
char *argv[])
784 return rw_test (argc, argv, __FILE__,
std::Nested::test_uint64_t test_uint64_t
std::Nested::test_int_fast64_t test_int_fast64_t
std::Nested::test_intptr_t test_intptr_t
#define TEST_REQUIRED_TYPE(name, bits, exact)
std::Nested::test_int_least16_t test_int_least16_t
std::Nested::test_int_least32_t test_int_least32_t
std::Nested::test_uint_least16_t test_uint_least16_t
std::Nested::test_intmax_t test_intmax_t
std::Nested::test_uint_least64_t test_uint_least64_t
#define DEFINE_TYPE(name)
std::Nested::test_uint16_t test_uint16_t
std::Nested::test_uint8_t test_uint8_t
std::Nested::test_uint_fast8_t test_uint_fast8_t
std::Nested::test_uint_fast16_t test_uint_fast16_t
std::Nested::test_uint32_t test_uint32_t
std::Nested::test_int_fast8_t test_int_fast8_t
std::Nested::test_uintmax_t test_uintmax_t
#define TEST_MACRO_NO_TYPE(macro, bits, exact, valstr)
std::Nested::test_int_least8_t test_int_least8_t
std::Nested::test_int_fast16_t test_int_fast16_t
std::Nested::test_int8_t test_int8_t
#define TEST_OPTIONAL_TYPE(name, bits, exact)
std::Nested::test_int64_t test_int64_t
std::Nested::test_uint_least32_t test_uint_least32_t
std::Nested::test_int32_t test_int32_t
std::Nested::test_uintptr_t test_uintptr_t
std::Nested::test_int_fast32_t test_int_fast32_t
std::Nested::test_int_least64_t test_int_least64_t
std::Nested::test_uint_least8_t test_uint_least8_t
std::Nested::test_uint_fast32_t test_uint_fast32_t
void test_bits(int line, intT testval, int expect, bool exact, const char *type_name, const char *macro_name=0, const char *valstr=0)
std::Nested::test_uint_fast64_t test_uint_fast64_t
#define TEST_MACRO(T, macro, bits, exact, valstr)
std::Nested::test_int16_t test_int16_t
const char *const missing_macros[]
void test_types(Vector *, T *, Allocator)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
_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_note(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)