505 rw_info (0, 0, 0,
"checking for missing and masking macros");
513#ifdef _RWSTD_STRICT_ANSI
515 "masking macro %s unexpectedly defined",
519 "masking macro %s unexpectedly defined",
527#ifndef _RWSTD_NO_NAMESPACE
539 operator int ()
const {
return i_; }
552 operator int ()
const {
return i_; }
587template <
class StructTm>
598 "types %s::size_t, %1$s::mbstate_t, %1$s::wint_t, and %1$s::tm",
602 "%s::size_t not defined",
std_name);
604 "%s::mbstate_t not defined",
std_name);
606 "%s::wint_t not defined",
std_name);
620 "types %s::size_t, %1$s::mbstate_t, %1$s::wint_t, and %1$s::tm",
623 rw_note (0, 0, 0,
"_RWSTD_NO_NAMESPACE defined, cannot test");
634template <
class FileT,
class WCharT>
635int fwprintf (FileT*,
const WCharT*, ...) {
return ncalls++; }
637template <
class FileT,
class WCharT>
638int fwscanf (FileT*,
const WCharT*, ...) {
return ncalls++; }
640template <
class WCharT>
641int wprintf (
const WCharT* dummy, ...) {
return ncalls++; }
643template <
class WCharT>
644int wscanf (
const WCharT* dummy, ...) {
return ncalls++; }
646template <
class WCharT,
class SizeT>
647int swprintf (WCharT*, SizeT,
const WCharT* dummy, ...) {
return ncalls++; }
649template <
class WCharT>
650int swscanf (
const WCharT*,
const WCharT* dummy, ...) {
return ncalls++; }
652template <
class FileT,
class WCharT,
class VAList>
653int vfwprintf (FileT*,
const WCharT*, VAList) {
return ncalls++; }
655template <
class WCharT,
class VAList>
656int vwprintf (
const WCharT*, VAList) {
return ncalls++; }
658template <
class WCharT,
class SizeT,
class VAList>
659int vswprintf (WCharT*, SizeT,
const WCharT*, VAList) {
return ncalls++; }
661template <
class FileT>
664template <
class WCharT,
class FileT>
665WCharT* fgetws (WCharT*,
int, FileT*) {
ncalls++;
return 0; }
667template <
class WCharT,
class FileT>
670template <
class WCharT,
class FileT>
671int fputws (
const WCharT*, FileT*) {
return ncalls++; }
673template <
class FileT>
679template <
class WCharT,
class FileT>
682template <
class WCharT>
685template <
class WIntT,
class FileT>
688template <
class FileT>
689int fwide (FileT*,
int) {
return ncalls++; }
691template <
class WCharT>
692double wcstod (
const WCharT*, WCharT**) {
return ncalls++; }
694template <
class WCharT>
695long wcstol (
const WCharT*, WCharT**,
int) {
return ncalls++; }
697template <
class WCharT>
698unsigned long wcstoul (
const WCharT*, WCharT**,
int) {
return ncalls++; }
700template <
class WCharT>
701WCharT* wcscpy (WCharT*,
const WCharT*) {
ncalls++;
return 0; }
703template <
class WCharT,
class SizeT>
704WCharT* wcsncpy (WCharT*,
const WCharT*, SizeT) {
ncalls++;
return 0; }
706template <
class WCharT>
707WCharT* wcscat (WCharT*,
const WCharT*) {
ncalls++;
return 0; }
709template <
class WCharT,
class SizeT>
710WCharT* wcsncat (WCharT*,
const WCharT*, SizeT) {
ncalls++;
return 0; }
712template <
class WCharT>
713int wcscmp (
const WCharT*,
const WCharT*) {
return ncalls++; }
715template <
class WCharT>
716int wcscoll (
const WCharT*,
const WCharT*) {
return ncalls++; }
718template <
class WCharT,
class SizeT>
719int wcsncmp (
const WCharT*,
const WCharT*, SizeT) {
return ncalls++; }
721template <
class WCharT,
class SizeT>
722SizeT wcsxfrm (WCharT*,
const WCharT*, SizeT) {
return ncalls++; }
724template <
class WCharT>
725WCharT* wcschr (WCharT*, WCharT) {
ncalls++;
return 0; }
727template <
class WCharT>
730template <
class WCharT>
731WCharT* wcspbrk (WCharT*,
const WCharT*) {
ncalls++;
return 0; }
733template <
class WCharT>
734WCharT* wcsrchr (WCharT*, WCharT) {
ncalls++;
return 0; }
736template <
class WCharT>
739template <
class WCharT>
740WCharT* wcsstr (WCharT*,
const WCharT*) {
ncalls++;
return 0; }
742template <
class WCharT>
743WCharT* wcstok (WCharT*,
const WCharT*, WCharT**) {
ncalls++;
return 0; }
745template <
class WCharT>
748template <
class WCharT,
class SizeT>
749WCharT* wmemchr (WCharT*, WCharT, SizeT) {
ncalls++;
return 0; }
751template <
class WCharT,
class SizeT>
752int wmemcmp (
const WCharT*,
const WCharT*, SizeT) {
return ncalls++; }
754template <
class WCharT,
class SizeT>
755WCharT* wmemcpy (WCharT*,
const WCharT*, SizeT) {
ncalls++;
return 0; }
757template <
class WCharT,
class SizeT>
758WCharT* wmemmove (WCharT*,
const WCharT*, SizeT) {
ncalls++;
return 0; }
760template <
class WCharT,
class SizeT>
761WCharT* wmemset (WCharT*, WCharT, SizeT) {
ncalls++;
return 0; }
763template <
class WCharT,
class SizeT,
class StructTm>
764SizeT wcsftime (WCharT*, SizeT,
const WCharT*,
const StructTm*)
770template <
class WIntT>
771int wctob (WIntT) {
return ncalls++; }
773template <
class MBStateT>
774int mbsinit (
const MBStateT*) {
return ncalls++; }
776template <
class SizeT,
class MBStateT>
777SizeT mbrlen (
const char*, SizeT, MBStateT*) {
return ncalls++; }
779template <
class WCharT,
class SizeT,
class MBStateT>
780SizeT mbrtowc (WCharT*,
const char*, SizeT, MBStateT*) {
return ncalls++; }
782template <
class WCharT,
class MBStateT>
785template <
class WCharT,
class SizeT,
class MBStateT>
786SizeT mbsrtowcs (WCharT*,
const char**, SizeT, MBStateT*) {
return ncalls++; }
788template <
class WCharT,
class SizeT,
class MBStateT>
789SizeT wcsrtombs (
char*,
const WCharT**, SizeT, MBStateT*) {
return ncalls++; }
792template <
class WCharT>
793const WCharT* wcschr (
const WCharT*, WCharT) {
ncalls++;
return 0; }
795template <
class WCharT>
796const WCharT* wcspbrk (
const WCharT*,
const WCharT*) {
ncalls++;
return 0; }
798template <
class WCharT>
799const WCharT* wcsrchr (
const WCharT*, WCharT) {
ncalls++;
return 0; }
801template <
class WCharT>
802const WCharT* wcsstr (
const WCharT*,
const WCharT*) {
ncalls++;
return 0; }
804template <
class WCharT,
class SizeT>
805const WCharT* wmemchr (
const WCharT*, WCharT, SizeT) {
ncalls++;
return 0; }
812#define GET_TYPE_NAME(T) \
813 template <class Type> \
814 const char* get_type_name (T, Type) { \
815 return rw_any_t (Type ()).type_name (); \
817 const char* get_type_name (T, T) { return 0; } \
818 typedef void unused_typedef
828#ifndef _RWSTD_NO_LONG_LONG
833#ifndef _RWSTD_NO_NATIVE_WCHAR_T
841#define EVAL2(macro) !!(macro - 1)
842#define EVAL(name) EVAL2 (_RWSTD_NO_ ## name + 0)
843#define EVAL_IN_LIBC(name) EVAL (name ## _IN_LIBC)
846static int rw_opt_no_macros;
847static int rw_opt_no_types;
848static int rw_opt_no_functions;
849static int rw_opt_no_overloads;
854#define TEST(T, fun, args, macro, overload) \
856 cstr = (str = array); \
857 wcstr = (wstr = warray); \
858 *str = '\0'; *wstr = L'\0'; \
860 rw_info (0, 0, __LINE__, "%s::%s(" \
861 "%{?}%{:}/* %{?}non-%{;}const overload */%{;})", \
862 std_name, #fun, overload < 0, 0 == overload); \
863 const char* const return_type_name = \
864 get_type_name ((T)0, std::fun args); \
865 rw_warn (0 == ncalls, 0, __LINE__, \
867 "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) " \
868 "not declared (_RWSTD_NO_%s = %d, " \
869 "_RWSTD_NO_%s_IN_LIBC = %d)", \
870 std_name, #fun, overload < 0, 0 == overload, \
871 #macro, EVAL (macro), #macro, EVAL_IN_LIBC (macro)); \
873 rw_assert (0 == return_type_name, 0, __LINE__, "%s::%s(" \
874 "%{?}%{:}/* %{?}non-%{;}const overload */%{;}) " \
875 "expected return type %s, got %s", \
876 std_name, #fun, overload < 0, 0 == overload, \
877 #T, return_type_name); \
883 const char* cstr =
array;
885 wchar_t warray [32] =
L"";
887 wchar_t* wstr = warray;
888 const wchar_t* wcstr = warray;
892 const UniqType*
const uniqptr = 0;
897 TEST (
int, wprintf, (
L""), WPRINTF, -1);
898 TEST (
int, wprintf, (
L"", uniqptr), WPRINTF, -1);
900 TEST (
int, wscanf, (
L""), WSCANF, -1);
901 TEST (
int, wscanf, (
L"", uniqptr), WSCANF, -1);
903 TEST (
int, swprintf, (wstr,
size,
L""), SWPRINTF, -1);
904 TEST (
int, swprintf, (wstr,
size,
L"", uniqptr), SWPRINTF, -1);
906 TEST (
int, swscanf, (wstr,
L""), SWSCANF, -1);
907 TEST (
int, swscanf, (wstr,
L"", uniqptr), SWSCANF, -1);
909 TEST (
double, wcstod, (
L"", &wstr), WCSTOD, -1);
910 TEST (
long, wcstol, (
L"", &wstr,
i), WCSTOL, -1);
911 TEST (
unsigned long, wcstoul, (
L"", &wstr,
i), WCSTOUL, -1);
913 TEST (
wchar_t*, wcscpy, (wstr,
L""), WCSCPY, -1);
914 TEST (
wchar_t*, wcsncpy, (wstr,
L"",
size), WCSNCPY, -1);
915 TEST (
wchar_t*, wcscat, (wstr,
L""), WCSCAT, -1);
916 TEST (
int, wcscmp, (wstr,
L""), WCSCMP, -1);
917 TEST (
int, wcsncmp, (wstr,
L"",
size), WCSNCMP, -1);
923 TEST (
wchar_t*, wcstok, (wstr,
L"", &wstr), WCSTOK, -1);
926 TEST (
int, wmemcmp, (
L"",
L"",
size), WMEMCMP, -1);
927 TEST (
wchar_t*, wmemcpy, (wstr,
L"",
size), WMEMCPY, -1);
928 TEST (
wchar_t*, wmemmove, (wstr,
L"",
size), WMEMMOVE, -1);
929 TEST (
wchar_t*, wmemset, (wstr,
L'\0',
size), WMEMSET, -1);
933 int tm_buf [16] = { 0 };
950 TEST (
int, wctob, (wi), WCTOB, -1);
954 TEST (
int, mbsinit, (&state), MBSINIT, -1);
962 if (rw_opt_no_overloads) {
964 TEST (
wchar_t*, wmemchr, (
L"",
L'\0',
size), WMEMCHR, -1);
965 TEST (
wchar_t*, wcspbrk, (wcstr,
L""), WCSPBRK, -1);
966 TEST (
wchar_t*, wcsrchr, (
L"",
L'\0'), WCSRCHR, -1);
967 TEST (
wchar_t*, wcsstr, (
L"",
L""), WCSSTR, -1);
968 TEST (
wchar_t*, wcschr, (
L"",
L'\0'), WCSCHR, -1);
973 TEST (
const wchar_t*, wmemchr, (
L"",
L'\0',
size), WMEMCHR, 1);
974 TEST (
wchar_t*, wmemchr, (wstr,
L'\0',
size), WMEMCHR, 0);
976 TEST (
const wchar_t*, wcspbrk, (wcstr,
L""), WCSPBRK, 1);
977 TEST (
wchar_t*, wcspbrk, (wstr,
L""), WCSPBRK, 0);
979 TEST (
const wchar_t*, wcsrchr, (
L"",
L'\0'), WCSRCHR, 1);
980 TEST (
wchar_t*, wcsrchr, (wstr,
L'\0'), WCSRCHR, 0);
982 TEST (
const wchar_t*, wcsstr, (
L"",
L""), WCSSTR, 1);
983 TEST (
wchar_t*, wcsstr, (wstr,
L""), WCSSTR, 0);
985 TEST (
const wchar_t*, wcschr, (
L"",
L'\0'), WCSCHR, 1);
986 TEST (
wchar_t*, wcschr, (wstr,
L'\0'), WCSCHR, 0);
1021 char array [4] =
"";
1024 const char* cstr =
array;
1026 wchar_t warray [32] =
L"";
1028 wchar_t* wstr = warray;
1029 const wchar_t* wcstr = warray;
1033 const UniqType*
const uniqptr = 0;
1048 TEST (
int, fwide, (fp,
i), FWIDE, -1);
1050 TEST (
int, fwprintf, (fp,
L""), FWPRINTF, -1);
1051 TEST (
int, fwprintf, (fp,
L"", uniqptr), FWPRINTF, -1);
1053 TEST (
int, fwscanf, (fp,
L""), FWSCANF, -1);
1054 TEST (
int, fwscanf, (fp,
L"", uniqptr), FWSCANF, -1);
1056 TEST (
int, vfwprintf, (fp,
L"", va), VFWPRINTF, -1);
1059 TEST (
wchar_t*, fgetws, (wstr,
i, fp), FGETWS, -1);
1061 TEST (
int, fputws, (
L"", fp), FPUTWS, -1);
1076 if (rw_opt_no_macros)
1077 rw_note (0, 0, 0,
"test for macros disabled");
1081 if (rw_opt_no_types)
1082 rw_note (0, 0, 0,
"test for types disabled");
1086 if (rw_opt_no_functions)
1087 rw_note (0, 0, 0,
"test for functions disabled");
1100 return rw_test (argc, argv, __FILE__,
1106 "|-no-functions#0-1 "
1107 "|-no-overloads#0-1 ",
1110 &rw_opt_no_functions,
1111 &rw_opt_no_overloads);
#define TEST(T, fun, args, macro, overload)
void test_file_functions(int dummy,...)
int tm_defined(const StructTm *)
std::Nested::test_va_list test_va_list
std::Nested::test_FILE test_FILE
std::Nested::test_size_t test_size_t
std::Nested::test_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_RWSTD_NO_UNGETWC_IN_LIBC
@ _RWSTD_NO_WCSXFRM_IN_LIBC
@ _RWSTD_NO_WCSNCPY_IN_LIBC
@ _RWSTD_NO_WMEMMOVE_IN_LIBC
@ _RWSTD_NO_WCSCHR_IN_LIBC
@ _RWSTD_NO_WCRTOMB_IN_LIBC
@ _RWSTD_NO_WCSCOLL_IN_LIBC
@ _RWSTD_NO_WMEMCMP_IN_LIBC
@ _RWSTD_NO_WCSCMP_IN_LIBC
@ _RWSTD_NO_FGETWC_IN_LIBC
@ _RWSTD_NO_WCTOB_IN_LIBC
@ _RWSTD_NO_WCSTOD_IN_LIBC
@ _RWSTD_NO_MBSRTOWCS_IN_LIBC
@ _RWSTD_NO_FWPRINTF_IN_LIBC
@ _RWSTD_NO_WMEMSET_IN_LIBC
@ _RWSTD_NO_WSCANF_IN_LIBC
@ _RWSTD_NO_FWSCANF_IN_LIBC
const char *const masking_macros[]
void test_types(Vector *, T *, Allocator)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define va_start(va, name)
#define _RWSTD_UNUSED(arg)
#define _RWSTD_NAMESPACE(name)
_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_info(int, const char *, int, const char *,...)
_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 *,...)