From ed3cbf36416a385828e7a5987ca52cb42882d84b Mon Sep 17 00:00:00 2001 From: Jean Philippe Date: Sat, 8 Feb 2020 00:02:23 +0000 Subject: [PATCH 1/5] Changed macro constants to constexpr variables (#487) Fixes #270. --- stl/src/filesys.cpp | 9 +++++---- stl/src/ios.cpp | 8 ++++---- stl/src/iosptrs.cpp | 8 ++++---- stl/src/xlock.cpp | 21 +++++++++++---------- stl/src/xnotify.cpp | 12 ++++++------ stl/src/xstoflt.cpp | 26 +++++++++++++------------- stl/src/xstoul.cpp | 8 ++++---- stl/src/xstoull.cpp | 7 +++---- stl/src/xstoxflt.cpp | 28 ++++++++++++++-------------- stl/src/xtime.cpp | 29 +++++++++++++---------------- stl/src/xwstoflt.cpp | 28 ++++++++++++++-------------- stl/src/xwstoxfl.cpp | 28 ++++++++++++++-------------- 12 files changed, 105 insertions(+), 107 deletions(-) diff --git a/stl/src/filesys.cpp b/stl/src/filesys.cpp index ac16cf6f794..1e74200637d 100644 --- a/stl/src/filesys.cpp +++ b/stl/src/filesys.cpp @@ -267,9 +267,10 @@ _FS_DLL unsigned long long __CLRCALL_PURE_OR_CDECL _File_size(const wchar_t* _Fn // 1908 is leap year #2 // 1968 is leap year #17 -#define WIN_TICKS_PER_SECOND 10000000ULL -#define WIN_TICKS_FROM_EPOCH (((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * WIN_TICKS_PER_SECOND) +constexpr uint64_t _Win_ticks_per_second = 10000000ULL; +constexpr uint64_t _Win_ticks_from_epoch = ((1970 - 1601) * 365 + 3 * 24 + 17) * 86400ULL * _Win_ticks_per_second; + _FS_DLL int64_t __CLRCALL_PURE_OR_CDECL _Last_write_time(const wchar_t* _Fname) { // get last write time WIN32_FILE_ATTRIBUTE_DATA _Data; @@ -281,7 +282,7 @@ _FS_DLL int64_t __CLRCALL_PURE_OR_CDECL _Last_write_time(const wchar_t* _Fname) // success, convert time unsigned long long _Wtime = static_cast(_Data.ftLastWriteTime.dwHighDateTime) << 32 | _Data.ftLastWriteTime.dwLowDateTime; - return static_cast(_Wtime - WIN_TICKS_FROM_EPOCH); + return static_cast(_Wtime - _Win_ticks_from_epoch); } @@ -294,7 +295,7 @@ _FS_DLL int __CLRCALL_PURE_OR_CDECL _Set_last_write_time(const wchar_t* _Fname, } // convert to FILETIME and set - unsigned long long _Wtime = static_cast(_When) + WIN_TICKS_FROM_EPOCH; + unsigned long long _Wtime = static_cast(_When) + _Win_ticks_from_epoch; FILETIME _Ft; _Ft.dwLowDateTime = static_cast(_Wtime); // intentionally discard upper bits _Ft.dwHighDateTime = static_cast(_Wtime >> 32); diff --git a/stl/src/ios.cpp b/stl/src/ios.cpp index 4f0be30a97d..91ee2363d34 100644 --- a/stl/src/ios.cpp +++ b/stl/src/ios.cpp @@ -7,7 +7,7 @@ #include _STD_BEGIN -#define NSTDSTR 8 // cin, wcin, cout, wcout, cerr, wcerr, clog, wclog +constexpr int _Nstdstr = 8; // cin, wcin, cout, wcout, cerr, wcerr, clog, wclog // TRANSITION, ABI: _BADOFF is preserved for binary compatibility #if defined(_M_CEE_PURE) @@ -22,8 +22,8 @@ __PURE_APPDOMAIN_GLOBAL int ios_base::_Index = 0; // initialize source of unique __PURE_APPDOMAIN_GLOBAL bool ios_base::_Sync = true; // initialize synchronization flag -__PURE_APPDOMAIN_GLOBAL static ios_base* stdstr[NSTDSTR + 2] = {0}; // [1, NSTDSTR] hold pointers to standard streams -__PURE_APPDOMAIN_GLOBAL static char stdopens[NSTDSTR + 2] = {0}; // [1, NSTDSTR] hold open counts for standard streams +__PURE_APPDOMAIN_GLOBAL static ios_base* stdstr[_Nstdstr + 2] = {0}; // [1, _Nstdstr] hold pointers to standard streams +__PURE_APPDOMAIN_GLOBAL static char stdopens[_Nstdstr + 2] = {0}; // [1, _Nstdstr] hold open counts for standard streams // void __CLR_OR_THIS_CALL ios_base::clear(iostate state, bool reraise) { // set state, possibly reraise exception // _Mystate = (iostate)(state & _Statmask); @@ -74,7 +74,7 @@ void __CLRCALL_PURE_OR_CDECL ios_base::_Ios_base_dtor(ios_base* _This) { // dest void __CLRCALL_PURE_OR_CDECL ios_base::_Addstd(ios_base* _This) { // add standard stream to destructor list _BEGIN_LOCK(_LOCK_STREAM) - for (_This->_Stdstr = 0; ++_This->_Stdstr < NSTDSTR;) { + for (_This->_Stdstr = 0; ++_This->_Stdstr < _Nstdstr;) { if (stdstr[_This->_Stdstr] == 0 || stdstr[_This->_Stdstr] == _This) { break; // found a candidate } diff --git a/stl/src/iosptrs.cpp b/stl/src/iosptrs.cpp index 4f7626d8f68..1390583e078 100644 --- a/stl/src/iosptrs.cpp +++ b/stl/src/iosptrs.cpp @@ -30,11 +30,11 @@ __PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream* _Ptr_wclog = 0; _STD_END // FINALIZATION CODE -#define NATS 10 // fclose, xgetloc, locks, facet free, etc. +constexpr int _Nats = 10; // fclose, xgetloc, locks, facet free, etc. // static data -__PURE_APPDOMAIN_GLOBAL static void(__cdecl* atfuns_cdecl[NATS])() = {0}; -__PURE_APPDOMAIN_GLOBAL static size_t atcount_cdecl = {NATS}; +__PURE_APPDOMAIN_GLOBAL static void(__cdecl* atfuns_cdecl[_Nats])() = {0}; +__PURE_APPDOMAIN_GLOBAL static size_t atcount_cdecl = {_Nats}; _MRTIMP2 void __cdecl _Atexit(void(__cdecl* pf)()) { // add to wrapup list if (atcount_cdecl == 0) { abort(); // stack full, give up @@ -45,7 +45,7 @@ _MRTIMP2 void __cdecl _Atexit(void(__cdecl* pf)()) { // add to wrapup list struct _Init_atexit { // controller for atexit processing __CLR_OR_THIS_CALL ~_Init_atexit() noexcept { // process wrapup functions - while (atcount_cdecl < NATS) { + while (atcount_cdecl < _Nats) { void(__cdecl * pf)() = (void(__cdecl*)()) DecodePointer(atfuns_cdecl[atcount_cdecl++]); if (pf) { (*pf)(); diff --git a/stl/src/xlock.cpp b/stl/src/xlock.cpp index 80eafb295b1..bbd37779368 100644 --- a/stl/src/xlock.cpp +++ b/stl/src/xlock.cpp @@ -11,12 +11,12 @@ _STD_BEGIN -#define MAX_LOCK 8 // must be power of two +constexpr int _Max_lock = 8; // must be power of two #pragma warning(disable : 4074) #pragma init_seg(compiler) -static _Rmtx mtx[MAX_LOCK]; +static _Rmtx mtx[_Max_lock]; static long init = -1; #if !defined(MRTDLL) @@ -70,7 +70,7 @@ __thiscall _Lockit::_Lockit() noexcept : _Locktype(0) { // lock default mutex __thiscall _Lockit::_Lockit(int kind) noexcept : _Locktype(kind) { // lock the mutex if (_Locktype == _LOCK_LOCALE) { _lock_locales(); - } else if (_Locktype < MAX_LOCK) { + } else if (_Locktype < _Max_lock) { _Mtxlock(&mtx[_Locktype]); } } @@ -78,7 +78,7 @@ __thiscall _Lockit::_Lockit(int kind) noexcept : _Locktype(kind) { // lock the m __thiscall _Lockit::~_Lockit() noexcept { // unlock the mutex if (_Locktype == _LOCK_LOCALE) { _unlock_locales(); - } else if (_Locktype < MAX_LOCK) { + } else if (_Locktype < _Max_lock) { _Mtxunlock(&mtx[_Locktype]); } } @@ -93,7 +93,7 @@ void __cdecl _Lockit::_Lockit_ctor(_Lockit* _This, int kind) noexcept { // lock if (kind == _LOCK_LOCALE) { _lock_locales(); } else { - _This->_Locktype = kind & (MAX_LOCK - 1); + _This->_Locktype = kind & (_Max_lock - 1); _Mtxlock(&mtx[_This->_Locktype]); } } @@ -107,7 +107,7 @@ void __cdecl _Lockit::_Lockit_ctor(int kind) noexcept { // lock the mutex if (kind == _LOCK_LOCALE) { _lock_locales(); } else { - _Mtxlock(&mtx[kind & (MAX_LOCK - 1)]); + _Mtxlock(&mtx[kind & (_Max_lock - 1)]); } } @@ -116,16 +116,17 @@ void __cdecl _Lockit::_Lockit_dtor(int kind) noexcept { // unlock the mutex if (kind == _LOCK_LOCALE) { _unlock_locales(); } else { - _Mtxunlock(&mtx[kind & (MAX_LOCK - 1)]); + _Mtxunlock(&mtx[kind & (_Max_lock - 1)]); } } -extern "C" void _Lock_at_thread_exit_mutex() { // lock the at-thread-exit mutex +_EXTERN_C +void _Lock_at_thread_exit_mutex() { // lock the at-thread-exit mutex _Mtxlock(&mtx[_LOCK_AT_THREAD_EXIT]); } - -extern "C" void _Unlock_at_thread_exit_mutex() { // unlock the at-thread-exit mutex +void _Unlock_at_thread_exit_mutex() { // unlock the at-thread-exit mutex _Mtxunlock(&mtx[_LOCK_AT_THREAD_EXIT]); } +_END_EXTERN_C _STD_END diff --git a/stl/src/xnotify.cpp b/stl/src/xnotify.cpp index 1a4b0fb9e9e..c3e87255399 100644 --- a/stl/src/xnotify.cpp +++ b/stl/src/xnotify.cpp @@ -9,7 +9,7 @@ #include -#define NITEMS 20 +constexpr int _Nitems = 20; namespace { struct _At_thread_exit_data { // data for condition-variable slot @@ -20,7 +20,7 @@ namespace { }; struct _At_thread_exit_block { // block of condition-variable slots - _At_thread_exit_data data[NITEMS]; + _At_thread_exit_data data[_Nitems]; int num_used; _At_thread_exit_block* next; }; @@ -40,14 +40,14 @@ void _Cnd_register_at_thread_exit( _Lock_at_thread_exit_mutex(); while (block != 0) { // loop through list of blocks - if (block->num_used == NITEMS) { // block is full; move to next block and allocate + if (block->num_used == _Nitems) { // block is full; move to next block and allocate if (block->next == 0) { block->next = (_At_thread_exit_block*) calloc(1, sizeof(_At_thread_exit_block)); } block = block->next; } else { // found block with available space - for (int i = 0; i < NITEMS; ++i) { // find empty slot + for (int i = 0; i < _Nitems; ++i) { // find empty slot if (block->data[i].mtx == 0) { // store into empty slot block->data[i].id._Id = GetCurrentThreadId(); block->data[i].mtx = mtx; @@ -69,7 +69,7 @@ void _Cnd_unregister_at_thread_exit(_Mtx_t mtx) { // unregister condition variab _Lock_at_thread_exit_mutex(); while (block != 0) { // loop through list of blocks - for (int i = 0; block->num_used != 0 && i < NITEMS; ++i) { + for (int i = 0; block->num_used != 0 && i < _Nitems; ++i) { if (block->data[i].mtx == mtx) { // release slot block->data[i].mtx = 0; --block->num_used; @@ -88,7 +88,7 @@ void _Cnd_do_broadcast_at_thread_exit() { // notify condition variables waiting _Lock_at_thread_exit_mutex(); while (block != 0) { // loop through list of blocks - for (int i = 0; block->num_used != 0 && i < NITEMS; ++i) { + for (int i = 0; block->num_used != 0 && i < _Nitems; ++i) { if (block->data[i].mtx != 0 && block->data[i].id._Id == currentThreadId) { // notify and release slot if (block->data[i].res) { *block->data[i].res = 1; diff --git a/stl/src/xstoflt.cpp b/stl/src/xstoflt.cpp index 16199533a2f..9ef65dfe932 100644 --- a/stl/src/xstoflt.cpp +++ b/stl/src/xstoflt.cpp @@ -10,25 +10,25 @@ _EXTERN_C_UNLESS_PURE -#define BASE 10 // decimal -#define NDIG 9 // decimal digits per long word -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 10; // decimal +constexpr int _Ndig = 9; // decimal digits per long word +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _Stoflt(const char* s0, const char* s, char** endptr, long lo[], int maxsig) { // convert string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int sticky = 0; // note any nonzero digits discarded int word = 0; // just before current long word to fill - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == '0') { // strip leading zeros seen = 1; @@ -69,7 +69,7 @@ int _Stoflt(const char* s0, const char* s, char** endptr, long lo[], } if (sticky) { - buf[maxsig - 1] += 1; // okay if digit becomes BASE + buf[maxsig - 1] += 1; // okay if digit becomes _Base } for (; 0 < nsig && buf[nsig - 1] == '\0'; --nsig) { @@ -82,14 +82,14 @@ int _Stoflt(const char* s0, const char* s, char** endptr, long lo[], if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } diff --git a/stl/src/xstoul.cpp b/stl/src/xstoul.cpp index df57338efb7..d43dbc91dbe 100644 --- a/stl/src/xstoul.cpp +++ b/stl/src/xstoul.cpp @@ -14,7 +14,7 @@ _EXTERN_C_UNLESS_PURE // macros -#define BASE_MAX 36 // largest valid base +constexpr int _Base_max = 36; // largest valid base // static data static const char digits[] = // valid digits @@ -22,11 +22,11 @@ static const char digits[] = // valid digits #if (ULONG_MAX >> 16) >> 16 == 0xffffffff // 64-bits! -static const char ndigs[BASE_MAX + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, +static const char ndigs[_Base_max + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13}; #else // (ULONG_MAX >> 16) >> 16 == 0xffffffff // 32-bits! -static const char ndigs[BASE_MAX + 1] = {0, 0, 33, 21, 17, 14, 13, 12, 11, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, +static const char ndigs[_Base_max + 1] = {0, 0, 33, 21, 17, 14, 13, 12, 11, 11, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; #endif // (ULONG_MAX >> 16) >> 16 == 0xffffffff @@ -49,7 +49,7 @@ _CRTIMP2_PURE unsigned long __CLRCALL_PURE_OR_CDECL _Stoulx( } sign = *sc == '-' || *sc == '+' ? *sc++ : '+'; - if (base < 0 || base == 1 || BASE_MAX < base) { // silly base + if (base < 0 || base == 1 || _Base_max < base) { // silly base if (endptr != 0) { *endptr = (char*) s; } diff --git a/stl/src/xstoull.cpp b/stl/src/xstoull.cpp index d236cc8c030..1c5ceb13fb7 100644 --- a/stl/src/xstoull.cpp +++ b/stl/src/xstoull.cpp @@ -13,14 +13,13 @@ _EXTERN_C_UNLESS_PURE -// macros -#define BASE_MAX 36 // largest valid base +constexpr int _Base_max = 36; // largest valid base // static data static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; // valid digits // 64-bits! -static const char ndigs[BASE_MAX + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, +static const char ndigs[_Base_max + 1] = {0, 0, 65, 41, 33, 28, 25, 23, 22, 21, 20, 19, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13}; _CRTIMP2_PURE unsigned long long __CLRCALL_PURE_OR_CDECL _Stoullx( @@ -41,7 +40,7 @@ _CRTIMP2_PURE unsigned long long __CLRCALL_PURE_OR_CDECL _Stoullx( } sign = (char) (*sc == '-' || *sc == '+' ? *sc++ : '+'); - if (base < 0 || base == 1 || BASE_MAX < base) { // silly base + if (base < 0 || base == 1 || _Base_max < base) { // silly base if (endptr != 0) { *endptr = (char*) s; } diff --git a/stl/src/xstoxflt.cpp b/stl/src/xstoxflt.cpp index db63479d596..f679521d601 100644 --- a/stl/src/xstoxflt.cpp +++ b/stl/src/xstoxflt.cpp @@ -11,13 +11,13 @@ _EXTERN_C_UNLESS_PURE -#define BASE 16 // hexadecimal -#define NDIG 7 // hexadecimal digits per long element -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 16; // hexadecimal +constexpr int _Ndig = 7; // hexadecimal digits per long element +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], int maxsig) { // convert string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int word = 0; // current long word to fill @@ -27,13 +27,13 @@ int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], static const char vals[] = {// values of hex digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13, 14, 15}; - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == '0') { // strip leading zeros ++s; @@ -69,8 +69,8 @@ int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], } if (maxsig < nsig) { // discard excess digit after rounding up - if (BASE / 2 <= buf[maxsig]) { - ++buf[maxsig - 1]; // okay if digit becomes BASE + if (_Base / 2 <= buf[maxsig]) { + ++buf[maxsig - 1]; // okay if digit becomes _Base } nsig = maxsig; @@ -88,14 +88,14 @@ int _Stoxflt(const char* s0, const char* s, char** endptr, long lo[], lo[0] <<= 2; // change hex exponent to binary exponent if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } diff --git a/stl/src/xtime.cpp b/stl/src/xtime.cpp index ecc3ffd9569..f39d35031e0 100644 --- a/stl/src/xtime.cpp +++ b/stl/src/xtime.cpp @@ -8,19 +8,18 @@ #include #include -#define NSEC_PER_SEC 1000000000L -#define NSEC_PER_MSEC 1000000L -#define NSEC_PER_USEC 1000L -#define MSEC_PER_SEC 1000 +constexpr long _Nsec_per_sec = 1000000000L; +constexpr long _Nsec_per_msec = 1000000L; +constexpr int _Msec_per_sec = 1000; static void xtime_normalize(xtime* xt) { // adjust so that 0 <= nsec < 1 000 000 000 while (xt->nsec < 0) { // normalize target time xt->sec -= 1; - xt->nsec += NSEC_PER_SEC; + xt->nsec += _Nsec_per_sec; } - while (NSEC_PER_SEC <= xt->nsec) { // normalize target time + while (_Nsec_per_sec <= xt->nsec) { // normalize target time xt->sec += 1; - xt->nsec -= NSEC_PER_SEC; + xt->nsec -= _Nsec_per_sec; } } @@ -30,7 +29,7 @@ static xtime xtime_diff(const xtime* xt, xtime_normalize(&diff); if (diff.nsec < now->nsec) { // avoid underflow diff.sec -= now->sec + 1; - diff.nsec += NSEC_PER_SEC - now->nsec; + diff.nsec += _Nsec_per_sec - now->nsec; } else { // no underflow diff.sec -= now->sec; diff.nsec -= now->nsec; @@ -43,28 +42,26 @@ static xtime xtime_diff(const xtime* xt, } -#define EPOCH 0x19DB1DED53E8000i64 - -#define NSEC100_PER_SEC (NSEC_PER_SEC / 100) -#define NSEC100_PER_MSEC (NSEC_PER_MSEC / 100) +constexpr long long _Epoch = 0x19DB1DED53E8000LL; +constexpr long _Nsec100_per_sec = _Nsec_per_sec / 100; _EXTERN_C long long _Xtime_get_ticks() { // get system time in 100-nanosecond intervals since the epoch FILETIME ft; __crtGetSystemTimePreciseAsFileTime(&ft); - return ((static_cast(ft.dwHighDateTime)) << 32) + static_cast(ft.dwLowDateTime) - EPOCH; + return ((static_cast(ft.dwHighDateTime)) << 32) + static_cast(ft.dwLowDateTime) - _Epoch; } static void sys_get_time(xtime* xt) { // get system time with nanosecond resolution unsigned long long now = _Xtime_get_ticks(); - xt->sec = static_cast<__time64_t>(now / NSEC100_PER_SEC); - xt->nsec = static_cast(now % NSEC100_PER_SEC) * 100; + xt->sec = static_cast<__time64_t>(now / _Nsec100_per_sec); + xt->nsec = static_cast(now % _Nsec100_per_sec) * 100; } long _Xtime_diff_to_millis2(const xtime* xt1, const xtime* xt2) { // convert time to milliseconds xtime diff = xtime_diff(xt1, xt2); - return static_cast(diff.sec * MSEC_PER_SEC + (diff.nsec + NSEC_PER_MSEC - 1) / NSEC_PER_MSEC); + return static_cast(diff.sec * _Msec_per_sec + (diff.nsec + _Nsec_per_msec - 1) / _Nsec_per_msec); } long _Xtime_diff_to_millis(const xtime* xt) { // convert time to milliseconds diff --git a/stl/src/xwstoflt.cpp b/stl/src/xwstoflt.cpp index 3cbfce6c705..983723c4c4a 100644 --- a/stl/src/xwstoflt.cpp +++ b/stl/src/xwstoflt.cpp @@ -10,24 +10,24 @@ _EXTERN_C_UNLESS_PURE -#define BASE 10 // decimal -#define NDIG 9 // decimal digits per long element -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 10; // decimal +constexpr int _Ndig = 9; // decimal digits per long element +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], int maxsig) { // convert wide string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int word = 0; // current long word to fill - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == L'0') { // strip leading zeros ++s; @@ -68,8 +68,8 @@ int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], } if (maxsig < nsig) { // discard excess digit after rounding up - if (BASE / 2 <= buf[maxsig]) { - ++buf[maxsig - 1]; // okay if digit becomes BASE + if (_Base / 2 <= buf[maxsig]) { + ++buf[maxsig - 1]; // okay if digit becomes _Base } nsig = maxsig; @@ -86,14 +86,14 @@ int _WStoflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } diff --git a/stl/src/xwstoxfl.cpp b/stl/src/xwstoxfl.cpp index ab17bfab5b1..4b5aceb4480 100644 --- a/stl/src/xwstoxfl.cpp +++ b/stl/src/xwstoxfl.cpp @@ -11,13 +11,13 @@ _EXTERN_C_UNLESS_PURE -#define BASE 16 // hexadecimal -#define NDIG 7 // hexadecimal digits per long element -#define MAXSIG (5 * NDIG) // maximum significant digits to keep +constexpr int _Base = 16; // hexadecimal +constexpr int _Ndig = 7; // hexadecimal digits per long element +constexpr int _Maxsig = 5 * _Ndig; // maximum significant digits to keep int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], int maxsig) { // convert wide string to array of long plus exponent - char buf[MAXSIG + 1]; // worst case, with room for rounding digit + char buf[_Maxsig + 1]; // worst case, with room for rounding digit int nsig = 0; // number of significant digits seen int seen = 0; // any valid field characters seen int word = 0; // current long word to fill @@ -29,13 +29,13 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], static const char vals[] = {// values of hex digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13, 14, 15}; - maxsig *= NDIG; // convert word count to digit count - if (MAXSIG < maxsig) { - maxsig = MAXSIG; // protect against bad call + maxsig *= _Ndig; // convert word count to digit count + if (_Maxsig < maxsig) { + maxsig = _Maxsig; // protect against bad call } lo[0] = 0; // power of ten exponent - lo[1] = 0; // first NDIG-digit word of fraction + lo[1] = 0; // first _Ndig-digit word of fraction while (*s == L'0') { // strip leading zeros ++s; @@ -74,8 +74,8 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], } if (maxsig < nsig) { // discard excess digit after rounding up - if (BASE / 2 <= buf[maxsig]) { - ++buf[maxsig - 1]; // okay if digit becomes BASE + if (_Base / 2 <= buf[maxsig]) { + ++buf[maxsig - 1]; // okay if digit becomes _Base } nsig = maxsig; @@ -93,14 +93,14 @@ int _WStoxflt(const wchar_t* s0, const wchar_t* s, wchar_t** endptr, long lo[], lo[0] <<= 2; // change hex exponent to binary exponent if (seen) { // convert digit sequence to words int bufidx = 0; // next digit in buffer - int wordidx = NDIG - nsig % NDIG; // next digit in word (% NDIG) + int wordidx = _Ndig - nsig % _Ndig; // next digit in word (% _Ndig) - word = wordidx % NDIG == 0 ? 0 : 1; + word = wordidx % _Ndig == 0 ? 0 : 1; for (; bufidx < nsig; ++wordidx, ++bufidx) { - if (wordidx % NDIG == 0) { + if (wordidx % _Ndig == 0) { lo[++word] = buf[bufidx]; } else { - lo[word] = lo[word] * BASE + buf[bufidx]; + lo[word] = lo[word] * _Base + buf[bufidx]; } } From 2b2746dd78d06493cb204e8616beec7991d72840 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 14 Feb 2020 14:00:55 -0800 Subject: [PATCH 2/5] Add the std test suite. (#498) * Add tests/std. * Update other files. NOTICE.txt Mention the LLVM Project, as its code appears in tests/std/tests/P0220R1_optional/test.cpp and elsewhere. azure-devops/enforce-clang-format.cmd Process everything within tests. This includes libcxx, std, and tr1. docs/cgmanifest.json Update this file for Microsoft-internal purposes. (It records the commit hashes of repos whose source code we've incorporated into our own repo. For llvm-project, this is distinct from the submodule's current commit.) tests/tr1/run.pl Mention runbe.pl in lowercase, to match the file itself. * Improve run.pl and runbe.pl comments. --- NOTICE.txt | 10 + azure-devops/enforce-clang-format.cmd | 2 +- docs/cgmanifest.json | 13 +- tests/std/include/constexpr_char_traits.hpp | 111 + .../std/include/floating_point_test_cases.hpp | 275 + tests/std/include/input_iterator.hpp | 206 + tests/std/include/instantiate_algorithms.hpp | 837 ++ .../include/instantiate_algorithms_int.hpp | 19 + .../instantiate_algorithms_nontrivial.hpp | 75 + .../instantiate_algorithms_op_deref.hpp | 342 + ...nstantiate_containers_iterators_common.hpp | 165 + .../include/parallel_algorithms_utilities.hpp | 27 + tests/std/include/test_death.hpp | 150 + tests/std/include/test_filesystem_support.hpp | 37 + tests/std/include/test_regex_support.hpp | 242 + tests/std/include/test_thread_support.hpp | 82 + tests/std/include/test_windows.h | 6 + tests/std/run.pl | 45 + tests/std/runbe.pl | 23 + tests/std/test.lst | 321 + .../Dev08_496675_iostream_int_reading/env.lst | 4 + .../test.cpp | 38 + .../Dev08_527068_scl_no_exceptions/env.lst | 7 + .../Dev08_527068_scl_no_exceptions/test.cpp | 69 + tests/std/tests/Dev08_563686_ostream/env.lst | 4 + tests/std/tests/Dev08_563686_ostream/test.cpp | 69 + .../Dev08_563705_std_malloc_free/env.lst | 4 + .../Dev08_563705_std_malloc_free/test.cpp | 32 + .../tests/Dev08_576265_list_remove/env.lst | 4 + .../tests/Dev08_576265_list_remove/test.cpp | 30 + tests/std/tests/Dev08_584299_search_n/env.lst | 4 + .../std/tests/Dev08_584299_search_n/test.cpp | 40 + .../tests/Dev09_012361_vector_swap/env.lst | 4 + .../tests/Dev09_012361_vector_swap/test.cpp | 156 + .../env.lst | 4 + .../test.cpp | 113 + .../custombuild.pl | 12 + .../tests/Dev09_056375_locale_cleanup/env.lst | 4 + .../Dev09_056375_locale_cleanup/test.cpp | 56 + .../Dev09_056375_locale_cleanup/testdll.cpp | 27 + .../Dev09_098637_stl_function_typeids/env.lst | 4 + .../test.cpp | 21 + .../env.lst | 4 + .../test.cpp | 11 + .../Dev09_119644_compiler_option_gz/env.lst | 4 + .../Dev09_119644_compiler_option_gz/test.cpp | 13 + .../env.lst | 4 + .../test.cpp | 123 + .../tests/Dev09_130060_unique_copy/env.lst | 4 + .../tests/Dev09_130060_unique_copy/test.cpp | 68 + .../Dev09_152755_tr1_nested_bind/env.lst | 4 + .../Dev09_152755_tr1_nested_bind/test.cpp | 36 + .../tests/Dev09_153419_tr1_allocators/env.lst | 4 + .../Dev09_153419_tr1_allocators/test.cpp | 453 + .../env.lst | 4 + .../test.cpp | 32 + .../Dev09_155328_tr1_vector_of_set/env.lst | 4 + .../Dev09_155328_tr1_vector_of_set/test.cpp | 20 + .../env.lst | 4 + .../test.cpp | 157 + .../env.lst | 4 + .../test.cpp | 350 + .../env.lst | 4 + .../test.cpp | 25 + .../tests/Dev09_165853_tr1_tuple_swap/env.lst | 4 + .../Dev09_165853_tr1_tuple_swap/test.cpp | 27 + .../env.lst | 4 + .../test.cpp | 25 + .../env.lst | 4 + .../test.cpp | 72 + .../env.lst | 4 + .../test.cpp | 23 + .../tests/Dev09_172666_tr1_tuple_odr/env.lst | 4 + .../tests/Dev09_172666_tr1_tuple_odr/one.cpp | 25 + .../tests/Dev09_172666_tr1_tuple_odr/two.cpp | 8 + .../tests/Dev09_173612_tr1_regex_leak/env.lst | 4 + .../Dev09_173612_tr1_regex_leak/test.cpp | 210 + .../env.lst | 4 + .../test.cpp | 125 + .../env.lst | 4 + .../test.cpp | 54 + .../env.lst | 4 + .../test.cpp | 18 + .../env.lst | 4 + .../test.cpp | 17 + .../env.lst | 4 + .../test.cpp | 37 + .../env.lst | 4 + .../test.cpp | 120 + .../tests/Dev09_182017_tr1_search_n/env.lst | 4 + .../tests/Dev09_182017_tr1_search_n/test.cpp | 51 + .../Dev09_186118_stoullx_corner_cases/env.lst | 4 + .../test.cpp | 26 + .../env.lst | 4 + .../test.cpp | 169 + .../env.lst | 4 + .../test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 83 + .../env.lst | 4 + .../test.cpp | 34 + .../Dev10_391723_bind_result_type/env.lst | 4 + .../Dev10_391723_bind_result_type/test.cpp | 55 + .../env.lst | 4 + .../test.cpp | 20 + .../env.lst | 4 + .../test.cpp | 21 + .../tests/Dev10_445289_make_shared/env.lst | 4 + .../tests/Dev10_445289_make_shared/test.cpp | 328 + .../env.lst | 4 + .../test.cpp | 18 + .../Dev10_482830_header_only_string/env.lst | 4 + .../Dev10_482830_header_only_string/test.cpp | 62 + .../Dev10_491486_floating_point_hash/env.lst | 4 + .../Dev10_491486_floating_point_hash/test.cpp | 62 + .../Dev10_492345_tr1_function_swap/env.lst | 4 + .../Dev10_492345_tr1_function_swap/test.cpp | 186 + .../env.lst | 4 + .../test.cpp | 38 + .../env.lst | 4 + .../test.cpp | 294 + .../env.lst | 4 + .../test.cpp | 96 + .../env.lst | 4 + .../test.cpp | 93 + .../Dev10_561430_list_and_tree_leaks/env.lst | 4 + .../Dev10_561430_list_and_tree_leaks/test.cpp | 240 + .../std/tests/Dev10_562056_tree_leak/env.lst | 4 + .../std/tests/Dev10_562056_tree_leak/test.cpp | 122 + .../env.lst | 4 + .../test.cpp | 33 + .../Dev10_567556_move_from_empty_list/env.lst | 4 + .../test.cpp | 52 + .../tests/Dev10_579381_vector_grow_to/env.lst | 4 + .../Dev10_579381_vector_grow_to/test.cpp | 98 + .../tests/Dev10_590599_hash_string/env.lst | 4 + .../tests/Dev10_590599_hash_string/test.cpp | 59 + .../env.lst | 4 + .../test.cpp | 8 + .../std/tests/Dev10_617014_tuple_tie/env.lst | 4 + .../std/tests/Dev10_617014_tuple_tie/test.cpp | 34 + .../tests/Dev10_632876_regex_proxy/env.lst | 4 + .../tests/Dev10_632876_regex_proxy/test.cpp | 94 + .../Dev10_635436_shared_ptr_reset/env.lst | 4 + .../Dev10_635436_shared_ptr_reset/test.cpp | 221 + .../tests/Dev10_639436_const_map_at/env.lst | 4 + .../tests/Dev10_639436_const_map_at/test.cpp | 37 + .../Dev10_646244_bad_alloc_message/env.lst | 4 + .../Dev10_646244_bad_alloc_message/test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 30 + .../env.lst | 4 + .../test.cpp | 96 + .../Dev10_661739_tuple_copy_ctors/env.lst | 4 + .../Dev10_661739_tuple_copy_ctors/test.cpp | 66 + .../Dev10_682964_stable_sort_warnings/env.lst | 4 + .../test.cpp | 112 + .../env.lst | 4 + .../test.cpp | 47 + .../env.lst | 4 + .../test.cpp | 358 + .../env.lst | 4 + .../test.cpp | 799 ++ .../Dev10_722102_shared_ptr_nullptr/env.lst | 4 + .../Dev10_722102_shared_ptr_nullptr/test.cpp | 496 + .../env.lst | 4 + .../test.cpp | 27 + .../Dev10_766948_insert_ambiguity/env.lst | 4 + .../Dev10_766948_insert_ambiguity/test.cpp | 157 + .../Dev10_780098_movable_elements/env.lst | 4 + .../Dev10_780098_movable_elements/test.cpp | 185 + .../Dev10_783436_rvalue_string_plus/env.lst | 4 + .../Dev10_783436_rvalue_string_plus/test.cpp | 35 + .../env.lst | 4 + .../test.cpp | 213 + .../env.lst | 4 + .../test.cpp | 121 + .../env.lst | 4 + .../test.cpp | 29 + .../env.lst | 4 + .../test.cpp | 121 + .../env.lst | 4 + .../test.cpp | 51 + .../tests/Dev10_860410_bitset_ctors/env.lst | 4 + .../tests/Dev10_860410_bitset_ctors/test.cpp | 270 + .../env.lst | 4 + .../test.cpp | 49 + .../env.lst | 4 + .../test.cpp | 203 + .../env.lst | 4 + .../test.cpp | 18 + .../Dev10_905461_is_sorted_until/env.lst | 4 + .../Dev10_905461_is_sorted_until/test.cpp | 64 + .../Dev10_908702_string_memory_leak/env.lst | 4 + .../Dev10_908702_string_memory_leak/test.cpp | 52 + .../Dev10_909646_stringstream_vd2/env.lst | 6 + .../Dev10_909646_stringstream_vd2/test.cpp | 36 + .../env.lst | 4 + .../test.cpp | 461 + .../Dev11_0000000_function_crashes/env.lst | 4 + .../Dev11_0000000_function_crashes/test.cpp | 83 + .../env.lst | 4 + .../test.cpp | 8 + .../env.lst | 4 + .../test.cpp | 211 + tests/std/tests/Dev11_0000000_quoted/env.lst | 4 + tests/std/tests/Dev11_0000000_quoted/test.cpp | 184 + .../tests/Dev11_0000000_rotate_test/env.lst | 4 + .../tests/Dev11_0000000_rotate_test/test.cpp | 67 + .../std/tests/Dev11_0000000_tuple_cat/env.lst | 4 + .../tests/Dev11_0000000_tuple_cat/test.cpp | 233 + .../env.lst | 4 + .../test.cpp | 879 ++ .../Dev11_0019127_singular_iterators/env.lst | 4 + .../Dev11_0019127_singular_iterators/test.cpp | 275 + .../env.lst | 4 + .../test.cpp | 166 + .../Dev11_0133625_locale0_implib_cpp/env.lst | 4 + .../Dev11_0133625_locale0_implib_cpp/test.cpp | 31 + .../env.lst | 4 + .../test.cpp | 82 + .../env.lst | 4 + .../test.cpp | 287 + .../tests/Dev11_0253803_debug_pointer/env.lst | 4 + .../Dev11_0253803_debug_pointer/test.cpp | 432 + .../tests/Dev11_0272959_make_signed/env.lst | 4 + .../tests/Dev11_0272959_make_signed/test.cpp | 225 + .../env.lst | 4 + .../test.cpp | 102 + .../env.lst | 4 + .../test.cpp | 185 + .../std/tests/Dev11_0302476_pair_move/env.lst | 4 + .../tests/Dev11_0302476_pair_move/test.cpp | 63 + .../env.lst | 4 + .../test.cpp | 92 + .../env.lst | 4 + .../test.cpp | 348 + .../env.lst | 4 + .../test.cpp | 219 + .../Dev11_0376122_grand_theft_bind/env.lst | 4 + .../Dev11_0376122_grand_theft_bind/test.cpp | 41 + .../env.lst | 4 + .../test.cpp | 71 + .../Dev11_0387701_container_equality/env.lst | 4 + .../Dev11_0387701_container_equality/test.cpp | 505 + .../Dev11_0417110_nullptr_t_is_scalar/env.lst | 4 + .../test.cpp | 68 + .../Dev11_0435439_call_once_deadlock/env.lst | 4 + .../Dev11_0435439_call_once_deadlock/test.cpp | 29 + .../Dev11_0437519_container_behavior/env.lst | 4 + .../Dev11_0437519_container_behavior/test.cpp | 322 + .../env.lst | 4 + .../test.cpp | 3040 +++++ .../Dev11_0447546_facet_allocation/env.lst | 4 + .../Dev11_0447546_facet_allocation/test.cpp | 76 + .../Dev11_0453373_codecvt_compiles/env.lst | 4 + .../Dev11_0453373_codecvt_compiles/test.cpp | 20 + .../env.lst | 4 + .../test.cpp | 108 + .../env.lst | 4 + .../test.cpp | 199 + .../env.lst | 7 + .../test.cpp | 57 + .../Dev11_0494593_time_put_wchar_t/env.lst | 4 + .../Dev11_0494593_time_put_wchar_t/test.cpp | 72 + .../tests/Dev11_0496153_locale_ctor/env.lst | 4 + .../tests/Dev11_0496153_locale_ctor/test.cpp | 49 + .../Dev11_0532622_minmax_element/env.lst | 4 + .../Dev11_0532622_minmax_element/test.cpp | 96 + .../Dev11_0535636_functional_overhaul/env.lst | 4 + .../test.cpp | 2204 ++++ .../env.lst | 4 + .../test.cpp | 32 + .../tests/Dev11_0577418_random_seed_0/env.lst | 4 + .../Dev11_0577418_random_seed_0/test.cpp | 32 + .../env.lst | 4 + .../test.cpp | 238 + .../env.lst | 4 + .../test.cpp | 184 + .../Dev11_0617384_empty_std_function/env.lst | 4 + .../Dev11_0617384_empty_std_function/test.cpp | 47 + .../Dev11_0653897_codecvt_partial/env.lst | 4 + .../Dev11_0653897_codecvt_partial/test.cpp | 75 + .../tests/Dev11_0671816_list_splice/env.lst | 4 + .../tests/Dev11_0671816_list_splice/test.cpp | 382 + .../Dev11_0696045_future_wait_for/env.lst | 4 + .../Dev11_0696045_future_wait_for/test.cpp | 53 + tests/std/tests/Dev11_0704582_ratio/env.lst | 4 + tests/std/tests/Dev11_0704582_ratio/test.cpp | 44 + .../env.lst | 4 + .../test.cpp | 150 + .../env.lst | 4 + .../test.cpp | 143 + .../Dev11_0823534_transparent_lookup/env.lst | 4 + .../Dev11_0823534_transparent_lookup/test.cpp | 272 + .../std/tests/Dev11_0835323_to_string/env.lst | 4 + .../tests/Dev11_0835323_to_string/test.cpp | 194 + .../std/tests/Dev11_0836436_get_time/env.lst | 4 + .../std/tests/Dev11_0836436_get_time/test.cpp | 212 + .../env.lst | 4 + .../test.cpp | 220 + .../env.lst | 4 + .../test.cpp | 575 + .../Dev11_0920385_list_sort_allocator/env.lst | 4 + .../test.cpp | 477 + .../tests/Dev11_1003120_search_test/env.lst | 4 + .../tests/Dev11_1003120_search_test/test.cpp | 83 + .../env.lst | 4 + .../test.cpp | 149 + .../env.lst | 4 + .../test.cpp | 380 + .../std/tests/Dev11_1074023_constexpr/env.lst | 4 + .../tests/Dev11_1074023_constexpr/test.cpp | 1023 ++ .../Dev11_1086953_call_once_overhaul/env.lst | 4 + .../Dev11_1086953_call_once_overhaul/test.cpp | 280 + .../env.lst | 4 + .../test.cpp | 107 + .../env.lst | 7 + .../test.cpp | 8 + .../Dev11_1131212_uncaught_exceptions/env.lst | 4 + .../test.cpp | 43 + .../Dev11_1137366_nested_exception/env.lst | 4 + .../Dev11_1137366_nested_exception/test.cpp | 199 + .../env.lst | 4 + .../test.cpp | 280 + .../tests/Dev11_1150223_shared_mutex/env.lst | 4 + .../tests/Dev11_1150223_shared_mutex/test.cpp | 352 + .../Dev11_1158803_regex_thread_safety/env.lst | 4 + .../test.cpp | 52 + .../env.lst | 4 + .../test.cpp | 90 + .../GH_000457_system_error_message/env.lst | 4 + .../GH_000457_system_error_message/test.cpp | 23 + .../env.lst | 4 + .../test.cpp | 77 + .../env.lst | 4 + .../test.cpp | 48 + .../env.lst | 4 + .../test.cpp | 59 + .../P0024R2_parallel_algorithms_count/env.lst | 4 + .../test.cpp | 48 + .../P0024R2_parallel_algorithms_equal/env.lst | 4 + .../test.cpp | 85 + .../env.lst | 4 + .../test.cpp | 209 + .../P0024R2_parallel_algorithms_find/env.lst | 4 + .../P0024R2_parallel_algorithms_find/test.cpp | 71 + .../env.lst | 4 + .../test.cpp | 129 + .../env.lst | 4 + .../test.cpp | 66 + .../env.lst | 4 + .../test.cpp | 72 + .../env.lst | 4 + .../test.cpp | 219 + .../env.lst | 4 + .../test.cpp | 125 + .../env.lst | 4 + .../test.cpp | 105 + .../env.lst | 4 + .../test.cpp | 123 + .../env.lst | 4 + .../test.cpp | 87 + .../env.lst | 4 + .../test.cpp | 65 + .../env.lst | 4 + .../test.cpp | 82 + .../env.lst | 4 + .../test.cpp | 96 + .../env.lst | 4 + .../test.cpp | 43 + .../env.lst | 4 + .../test.cpp | 120 + .../env.lst | 4 + .../test.cpp | 106 + .../env.lst | 4 + .../test.cpp | 183 + .../env.lst | 4 + .../test.cpp | 160 + .../P0024R2_parallel_algorithms_sort/env.lst | 4 + .../P0024R2_parallel_algorithms_sort/test.cpp | 42 + .../env.lst | 4 + .../test.cpp | 91 + .../env.lst | 4 + .../test.cpp | 85 + .../env.lst | 4 + .../test.cpp | 202 + .../env.lst | 4 + .../test.cpp | 229 + .../env.lst | 4 + .../test.cpp | 155 + .../P0035R4_over_aligned_allocation/env.lst | 4 + .../P0035R4_over_aligned_allocation/test.cpp | 87 + .../env.lst | 4 + .../test.cpp | 217 + ..._fixed_precision_to_chars_test_cases_1.hpp | 296 + ..._fixed_precision_to_chars_test_cases_2.hpp | 3473 +++++ ..._fixed_precision_to_chars_test_cases_3.hpp | 10828 ++++++++++++++++ ..._fixed_precision_to_chars_test_cases_4.hpp | 10807 +++++++++++++++ .../double_from_chars_test_cases.hpp | 1143 ++ ..._general_precision_to_chars_test_cases.hpp | 5028 +++++++ ...uble_hex_precision_to_chars_test_cases.hpp | 116 + ...ntific_precision_to_chars_test_cases_1.hpp | 290 + ...ntific_precision_to_chars_test_cases_2.hpp | 3215 +++++ ...ntific_precision_to_chars_test_cases_3.hpp | 10121 +++++++++++++++ ...ntific_precision_to_chars_test_cases_4.hpp | 10103 ++++++++++++++ .../double_to_chars_test_cases.hpp | 2912 +++++ tests/std/tests/P0067R5_charconv/env.lst | 6 + ...at_fixed_precision_to_chars_test_cases.hpp | 1260 ++ .../float_from_chars_test_cases.hpp | 136 + ..._general_precision_to_chars_test_cases.hpp | 1214 ++ ...loat_hex_precision_to_chars_test_cases.hpp | 102 + ...ientific_precision_to_chars_test_cases.hpp | 1089 ++ .../float_to_chars_test_cases.hpp | 537 + tests/std/tests/P0067R5_charconv/test.cpp | 1085 ++ tests/std/tests/P0067R5_charconv/test.hpp | 60 + .../P0083R3_splicing_maps_and_sets/env.lst | 4 + .../P0083R3_splicing_maps_and_sets/test.cpp | 650 + tests/std/tests/P0088R3_variant/env.lst | 34 + tests/std/tests/P0088R3_variant/test.cpp | 7130 ++++++++++ .../tests/P0092R1_polishing_chrono/env.lst | 4 + .../tests/P0092R1_polishing_chrono/test.cpp | 225 + tests/std/tests/P0122R7_span/env.lst | 4 + tests/std/tests/P0122R7_span/test.cpp | 1108 ++ tests/std/tests/P0122R7_span_death/env.lst | 4 + tests/std/tests/P0122R7_span_death/test.cpp | 346 + tests/std/tests/P0137R1_launder/env.lst | 4 + tests/std/tests/P0137R1_launder/test.cpp | 43 + tests/std/tests/P0156R2_scoped_lock/env.lst | 4 + tests/std/tests/P0156R2_scoped_lock/test.cpp | 280 + .../env.lst | 4 + .../test.cpp | 603 + tests/std/tests/P0218R1_filesystem/env.lst | 4 + tests/std/tests/P0218R1_filesystem/test.cpp | 3960 ++++++ tests/std/tests/P0220R1_any/env.lst | 4 + tests/std/tests/P0220R1_any/test.cpp | 3232 +++++ tests/std/tests/P0220R1_optional/env.lst | 4 + tests/std/tests/P0220R1_optional/test.cpp | 7514 +++++++++++ .../env.lst | 4 + .../test.cpp | 1468 +++ .../std/tests/P0220R1_sample/adapterator.hpp | 203 + tests/std/tests/P0220R1_sample/env.lst | 4 + tests/std/tests/P0220R1_sample/test.cpp | 89 + tests/std/tests/P0220R1_searchers/env.lst | 4 + tests/std/tests/P0220R1_searchers/test.cpp | 318 + tests/std/tests/P0220R1_string_view/env.lst | 4 + tests/std/tests/P0220R1_string_view/test.cpp | 1103 ++ tests/std/tests/P0325R4_to_array/env.lst | 4 + tests/std/tests/P0325R4_to_array/test.cpp | 65 + tests/std/tests/P0356R5_bind_front/env.lst | 4 + tests/std/tests/P0356R5_bind_front/test.cpp | 159 + .../env.lst | 4 + .../test.cpp | 29 + .../P0414R2_shared_ptr_for_arrays/env.lst | 4 + .../P0414R2_shared_ptr_for_arrays/test.cpp | 1014 ++ .../P0426R1_constexpr_char_traits/env.lst | 4 + .../P0426R1_constexpr_char_traits/test.cpp | 130 + .../tests/P0433R2_deduction_guides/env.lst | 4 + .../tests/P0433R2_deduction_guides/test.cpp | 968 ++ .../env.lst | 4 + .../test.cpp | 176 + .../tests/P0513R0_poisoning_the_hash/env.lst | 4 + .../tests/P0513R0_poisoning_the_hash/test.cpp | 266 + .../env.lst | 4 + .../test.cpp | 169 + .../env.lst | 4 + .../test.cpp | 112 + .../P0595R2_is_constant_evaluated/env.lst | 4 + .../P0595R2_is_constant_evaluated/test.cpp | 78 + .../tests/P0607R0_inline_variables/env.lst | 4 + .../tests/P0607R0_inline_variables/test.cpp | 27 + .../tests/P0607R0_inline_variables/test2.cpp | 13 + .../P0616R0_using_move_in_numeric/env.lst | 4 + .../P0616R0_using_move_in_numeric/test.cpp | 109 + .../P0631R8_numbers_math_constants/env.lst | 4 + .../P0631R8_numbers_math_constants/test.cpp | 131 + .../P0674R1_make_shared_for_arrays/env.lst | 4 + .../P0674R1_make_shared_for_arrays/test.cpp | 47 + .../P0758R1_is_nothrow_convertible/env.lst | 4 + .../P0758R1_is_nothrow_convertible/test.cpp | 111 + .../tests/P0768R1_spaceship_operator/env.lst | 4 + .../tests/P0768R1_spaceship_operator/test.cpp | 136 + .../P0769R2_shift_left_shift_right/env.lst | 4 + .../P0769R2_shift_left_shift_right/test.cpp | 145 + tests/std/tests/P0811R3_midpoint_lerp/env.lst | 4 + .../std/tests/P0811R3_midpoint_lerp/test.cpp | 825 ++ .../P0896R4_ranges_iterator_machinery/env.lst | 4 + .../test.cpp | 2776 ++++ .../P0896R4_ranges_range_machinery/env.lst | 4 + .../P0896R4_ranges_range_machinery/test.cpp | 1852 +++ .../tests/P0896R4_ranges_to_address/env.lst | 4 + .../tests/P0896R4_ranges_to_address/test.cpp | 139 + tests/std/tests/P0898R3_concepts/env.lst | 4 + .../tests/P0898R3_concepts/invocable_cc.hpp | 826 ++ tests/std/tests/P0898R3_concepts/test.cpp | 3593 +++++ tests/std/tests/P0898R3_identity/env.lst | 4 + tests/std/tests/P0898R3_identity/test.cpp | 50 + .../env.lst | 4 + .../test.cpp | 375 + .../env.lst | 4 + .../test.cpp | 133 + .../env.lst | 4 + .../test.cpp | 376 + .../tests/P1423R3_char8_t_remediation/env.lst | 4 + .../P1423R3_char8_t_remediation/test.cpp | 62 + .../tests/P1645R1_constexpr_numeric/env.lst | 4 + .../tests/P1645R1_constexpr_numeric/test.cpp | 235 + .../VSO_0000000_allocator_propagation/env.lst | 4 + .../test.cpp | 1694 +++ .../VSO_0000000_any_calling_conventions/a.cpp | 28 + .../ab.hpp | 31 + .../VSO_0000000_any_calling_conventions/b.cpp | 12 + .../custombuild.pl | 12 + .../env.lst | 14 + .../VSO_0000000_c_math_functions/both.cpp | 8 + .../VSO_0000000_c_math_functions/cmath.cpp | 5 + .../VSO_0000000_c_math_functions/cstdlib.cpp | 5 + .../VSO_0000000_c_math_functions/env.lst | 4 + .../type_asserts.hpp | 18 + .../env.lst | 4 + .../test.cpp | 178 + .../env.lst | 4 + .../test.cpp | 153 + .../env.lst | 4 + .../test.cpp | 86 + .../tests/VSO_0000000_fancy_pointers/env.lst | 4 + .../tests/VSO_0000000_fancy_pointers/test.cpp | 450 + .../tests/VSO_0000000_has_static_rtti/env.lst | 4 + .../VSO_0000000_has_static_rtti/test.cpp | 117 + .../VSO_0000000_initialize_everything/env.lst | 4 + .../test.cpp | 374 + .../env.lst | 4 + .../test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 12 + .../env.lst | 4 + .../test.cpp | 11 + .../env.lst | 4 + .../test.cpp | 11 + .../env.lst | 4 + .../test.cpp | 11 + .../env.lst | 4 + .../test.cpp | 11 + .../env.lst | 4 + .../test.cpp | 922 ++ .../tests/VSO_0000000_instantiate_cvt/env.lst | 4 + .../VSO_0000000_instantiate_cvt/test.cpp | 180 + .../env.lst | 4 + .../test.cpp | 2014 +++ .../env.lst | 4 + .../test.cpp | 339 + .../env.lst | 4 + .../test.cpp | 544 + .../env.lst | 4 + .../test.cpp | 81 + .../VSO_0000000_matching_npos_address/a.cpp | 16 + .../VSO_0000000_matching_npos_address/env.lst | 4 + .../main.cpp | 15 + .../env.lst | 4 + .../test.cpp | 731 ++ .../VSO_0000000_nullptr_stream_out/env.lst | 4 + .../VSO_0000000_nullptr_stream_out/test.cpp | 26 + .../tests/VSO_0000000_oss_workarounds/env.lst | 4 + .../VSO_0000000_oss_workarounds/test.cpp | 19 + .../VSO_0000000_path_stream_parameter/env.lst | 4 + .../test.cpp | 145 + .../tests/VSO_0000000_regex_interface/env.lst | 4 + .../VSO_0000000_regex_interface/test.cpp | 403 + tests/std/tests/VSO_0000000_regex_use/env.lst | 4 + .../std/tests/VSO_0000000_regex_use/test.cpp | 576 + .../VSO_0000000_strengthened_noexcept/env.lst | 4 + .../test.cpp | 49 + .../tests/VSO_0000000_string_view_idl/env.lst | 4 + .../VSO_0000000_string_view_idl/test.cpp | 253 + .../std/tests/VSO_0000000_type_traits/env.lst | 4 + .../tests/VSO_0000000_type_traits/test.cpp | 1486 +++ .../VSO_0000000_vector_algorithms/env.lst | 4 + .../VSO_0000000_vector_algorithms/test.cpp | 122 + .../env.lst | 4 + .../test.cpp | 48 + .../env.lst | 4 + .../test.cpp | 36 + .../env.lst | 4 + .../test.cpp | 49 + .../env.lst | 4 + .../test.cpp | 84 + .../VSO_0099869_pow_float_overflow/env.lst | 4 + .../VSO_0099869_pow_float_overflow/test.cpp | 94 + .../VSO_0102478_moving_allocators/env.lst | 4 + .../VSO_0102478_moving_allocators/test.cpp | 473 + .../env.lst | 4 + .../test.cpp | 120 + .../env.lst | 4 + .../test.cpp | 75 + .../VSO_0105317_expression_sfinae/env.lst | 4 + .../VSO_0105317_expression_sfinae/test.cpp | 734 ++ .../VSO_0118461_min_max_noexcept/env.lst | 4 + .../VSO_0118461_min_max_noexcept/test.cpp | 81 + .../env.lst | 4 + .../test.cpp | 169 + .../env.lst | 4 + .../test.cpp | 89 + .../env.lst | 4 + .../test.cpp | 164 + .../env.lst | 4 + .../test.cpp | 104 + .../std/tests/VSO_0144114_sleep_until/env.lst | 4 + .../tests/VSO_0144114_sleep_until/test.cpp | 62 + .../env.lst | 4 + .../test.cpp | 27 + .../env.lst | 4 + .../test.cpp | 10 + .../VSO_0157762_feature_test_macros/env.lst | 12 + .../VSO_0157762_feature_test_macros/test.cpp | 1853 +++ .../tests/VSO_0174871_string_replace/env.lst | 4 + .../tests/VSO_0174871_string_replace/test.cpp | 145 + .../VSO_0180466_algorithm_overhauls/env.lst | 4 + .../VSO_0180466_algorithm_overhauls/test.cpp | 389 + .../std/tests/VSO_0180469_fill_family/env.lst | 4 + .../tests/VSO_0180469_fill_family/test.cpp | 139 + tests/std/tests/VSO_0180469_ptr_cat/env.lst | 4 + tests/std/tests/VSO_0180469_ptr_cat/test.cpp | 401 + .../VSO_0191296_allocator_construct/env.lst | 4 + .../VSO_0191296_allocator_construct/test.cpp | 1728 +++ .../env.lst | 4 + .../test.cpp | 242 + .../VSO_0224478_scoped_allocator/env.lst | 4 + .../VSO_0224478_scoped_allocator/test.cpp | 161 + tests/std/tests/VSO_0226079_mutex/env.lst | 4 + tests/std/tests/VSO_0226079_mutex/test.cpp | 535 + .../VSO_0234888_num_get_overflows/env.lst | 4 + .../VSO_0234888_num_get_overflows/test.cpp | 323 + .../env.lst | 4 + .../test.cpp | 202 + .../tests/VSO_0397980_codecvt_length/env.lst | 4 + .../tests/VSO_0397980_codecvt_length/test.cpp | 225 + .../env.lst | 4 + .../test.cpp | 181 + .../VSO_0474901_shift_jis_codecvt/env.lst | 4 + .../VSO_0474901_shift_jis_codecvt/test.cpp | 47 + .../tests/VSO_0493909_is_aggregate/env.lst | 4 + .../tests/VSO_0493909_is_aggregate/test.cpp | 288 + .../env.lst | 4 + .../test.cpp | 42 + .../env.lst | 4 + .../test.cpp | 48 + .../env.lst | 4 + .../test.cpp | 40 + .../tests/VSO_0527559_pragma_managed/env.lst | 4 + .../tests/VSO_0527559_pragma_managed/test.cpp | 8 + .../env.lst | 4 + .../test.cpp | 43 + .../std/tests/VSO_0599804_seekg_zero/env.lst | 4 + .../std/tests/VSO_0599804_seekg_zero/test.cpp | 21 + .../tests/VSO_0644691_utf_8_codecvt/env.lst | 4 + .../tests/VSO_0644691_utf_8_codecvt/test.cpp | 266 + .../env.lst | 4 + .../test.cpp | 17 + .../VSO_0664587_lcg_divide_by_zero/env.lst | 4 + .../VSO_0664587_lcg_divide_by_zero/test.cpp | 19 + .../env.lst | 4 + .../test.cpp | 283 + .../VSO_0735700_fstream_read_over_4k/env.lst | 4 + .../VSO_0735700_fstream_read_over_4k/test.cpp | 62 + .../env.lst | 4 + .../test.cpp | 33 + .../env.lst | 4 + .../test.cpp | 25 + .../env.lst | 4 + .../test.cpp | 52 + .../env.lst | 4 + .../test.cpp | 347 + .../env.lst | 4 + .../test.cpp | 180 + .../tests/VSO_0938757_attribute_order/env.lst | 6 + .../VSO_0938757_attribute_order/test.cpp | 13 + .../VSO_0961751_hash_range_erase/env.lst | 4 + .../VSO_0961751_hash_range_erase/test.cpp | 508 + .../VSO_0971246_legacy_await_headers/env.lst | 9 + .../VSO_0971246_legacy_await_headers/test.cpp | 187 + tests/std/tests/callconv_matrix.lst | 10 + tests/std/tests/clr_matrix.lst | 7 + tests/std/tests/concepts_matrix.lst | 11 + tests/std/tests/eha_matrix.lst | 16 + tests/std/tests/fast_matrix.lst | 7 + tests/std/tests/impure_matrix.lst | 32 + .../include_each_header_alone_matrix.lst | 164 + tests/std/tests/locale0_implib_cpp_matrix.lst | 39 + tests/std/tests/native_17_matrix.lst | 28 + tests/std/tests/native_latest_matrix.lst | 24 + tests/std/tests/native_matrix.lst | 30 + tests/std/tests/native_winsdk_matrix.lst | 28 + tests/std/tests/prefix.lst | 4 + tests/std/tests/rtti_matrix.lst | 10 + tests/std/tests/usual_17_matrix.lst | 32 + tests/std/tests/usual_17_winsdk_matrix.lst | 28 + tests/std/tests/usual_latest_matrix.lst | 24 + .../std/tests/usual_latest_winsdk_matrix.lst | 22 + tests/std/tests/usual_matrix.lst | 34 + tests/std/tests/usual_winsdk_matrix.lst | 32 + tests/tr1/run.pl | 8 +- tests/tr1/runbe.pl | 1 - 710 files changed, 165285 insertions(+), 8 deletions(-) create mode 100644 tests/std/include/constexpr_char_traits.hpp create mode 100644 tests/std/include/floating_point_test_cases.hpp create mode 100644 tests/std/include/input_iterator.hpp create mode 100644 tests/std/include/instantiate_algorithms.hpp create mode 100644 tests/std/include/instantiate_algorithms_int.hpp create mode 100644 tests/std/include/instantiate_algorithms_nontrivial.hpp create mode 100644 tests/std/include/instantiate_algorithms_op_deref.hpp create mode 100644 tests/std/include/instantiate_containers_iterators_common.hpp create mode 100644 tests/std/include/parallel_algorithms_utilities.hpp create mode 100644 tests/std/include/test_death.hpp create mode 100644 tests/std/include/test_filesystem_support.hpp create mode 100644 tests/std/include/test_regex_support.hpp create mode 100644 tests/std/include/test_thread_support.hpp create mode 100644 tests/std/include/test_windows.h create mode 100644 tests/std/run.pl create mode 100644 tests/std/runbe.pl create mode 100644 tests/std/test.lst create mode 100644 tests/std/tests/Dev08_496675_iostream_int_reading/env.lst create mode 100644 tests/std/tests/Dev08_496675_iostream_int_reading/test.cpp create mode 100644 tests/std/tests/Dev08_527068_scl_no_exceptions/env.lst create mode 100644 tests/std/tests/Dev08_527068_scl_no_exceptions/test.cpp create mode 100644 tests/std/tests/Dev08_563686_ostream/env.lst create mode 100644 tests/std/tests/Dev08_563686_ostream/test.cpp create mode 100644 tests/std/tests/Dev08_563705_std_malloc_free/env.lst create mode 100644 tests/std/tests/Dev08_563705_std_malloc_free/test.cpp create mode 100644 tests/std/tests/Dev08_576265_list_remove/env.lst create mode 100644 tests/std/tests/Dev08_576265_list_remove/test.cpp create mode 100644 tests/std/tests/Dev08_584299_search_n/env.lst create mode 100644 tests/std/tests/Dev08_584299_search_n/test.cpp create mode 100644 tests/std/tests/Dev09_012361_vector_swap/env.lst create mode 100644 tests/std/tests/Dev09_012361_vector_swap/test.cpp create mode 100644 tests/std/tests/Dev09_052961_has_iterator_debugging_0/env.lst create mode 100644 tests/std/tests/Dev09_052961_has_iterator_debugging_0/test.cpp create mode 100644 tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl create mode 100644 tests/std/tests/Dev09_056375_locale_cleanup/env.lst create mode 100644 tests/std/tests/Dev09_056375_locale_cleanup/test.cpp create mode 100644 tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp create mode 100644 tests/std/tests/Dev09_098637_stl_function_typeids/env.lst create mode 100644 tests/std/tests/Dev09_098637_stl_function_typeids/test.cpp create mode 100644 tests/std/tests/Dev09_119637_throwing_string_with_hid0/env.lst create mode 100644 tests/std/tests/Dev09_119637_throwing_string_with_hid0/test.cpp create mode 100644 tests/std/tests/Dev09_119644_compiler_option_gz/env.lst create mode 100644 tests/std/tests/Dev09_119644_compiler_option_gz/test.cpp create mode 100644 tests/std/tests/Dev09_126254_persistent_aux_allocators/env.lst create mode 100644 tests/std/tests/Dev09_126254_persistent_aux_allocators/test.cpp create mode 100644 tests/std/tests/Dev09_130060_unique_copy/env.lst create mode 100644 tests/std/tests/Dev09_130060_unique_copy/test.cpp create mode 100644 tests/std/tests/Dev09_152755_tr1_nested_bind/env.lst create mode 100644 tests/std/tests/Dev09_152755_tr1_nested_bind/test.cpp create mode 100644 tests/std/tests/Dev09_153419_tr1_allocators/env.lst create mode 100644 tests/std/tests/Dev09_153419_tr1_allocators/test.cpp create mode 100644 tests/std/tests/Dev09_154033_tr1_predicate_search_n/env.lst create mode 100644 tests/std/tests/Dev09_154033_tr1_predicate_search_n/test.cpp create mode 100644 tests/std/tests/Dev09_155328_tr1_vector_of_set/env.lst create mode 100644 tests/std/tests/Dev09_155328_tr1_vector_of_set/test.cpp create mode 100644 tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/env.lst create mode 100644 tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/test.cpp create mode 100644 tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/env.lst create mode 100644 tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/test.cpp create mode 100644 tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/env.lst create mode 100644 tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/test.cpp create mode 100644 tests/std/tests/Dev09_165853_tr1_tuple_swap/env.lst create mode 100644 tests/std/tests/Dev09_165853_tr1_tuple_swap/test.cpp create mode 100644 tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/env.lst create mode 100644 tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/test.cpp create mode 100644 tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/env.lst create mode 100644 tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/test.cpp create mode 100644 tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/env.lst create mode 100644 tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/test.cpp create mode 100644 tests/std/tests/Dev09_172666_tr1_tuple_odr/env.lst create mode 100644 tests/std/tests/Dev09_172666_tr1_tuple_odr/one.cpp create mode 100644 tests/std/tests/Dev09_172666_tr1_tuple_odr/two.cpp create mode 100644 tests/std/tests/Dev09_173612_tr1_regex_leak/env.lst create mode 100644 tests/std/tests/Dev09_173612_tr1_regex_leak/test.cpp create mode 100644 tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/env.lst create mode 100644 tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/test.cpp create mode 100644 tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/env.lst create mode 100644 tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/test.cpp create mode 100644 tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/env.lst create mode 100644 tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/test.cpp create mode 100644 tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/env.lst create mode 100644 tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/test.cpp create mode 100644 tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/env.lst create mode 100644 tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/test.cpp create mode 100644 tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/env.lst create mode 100644 tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/test.cpp create mode 100644 tests/std/tests/Dev09_182017_tr1_search_n/env.lst create mode 100644 tests/std/tests/Dev09_182017_tr1_search_n/test.cpp create mode 100644 tests/std/tests/Dev09_186118_stoullx_corner_cases/env.lst create mode 100644 tests/std/tests/Dev09_186118_stoullx_corner_cases/test.cpp create mode 100644 tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/env.lst create mode 100644 tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/test.cpp create mode 100644 tests/std/tests/Dev09_195561_tr1_function_const_op/env.lst create mode 100644 tests/std/tests/Dev09_195561_tr1_function_const_op/test.cpp create mode 100644 tests/std/tests/Dev09_196243_tr1_enable_shared_from_this_ops/env.lst create mode 100644 tests/std/tests/Dev09_196243_tr1_enable_shared_from_this_ops/test.cpp create mode 100644 tests/std/tests/Dev09_199123_tr1_mem_fun_abstract_classes/env.lst create mode 100644 tests/std/tests/Dev09_199123_tr1_mem_fun_abstract_classes/test.cpp create mode 100644 tests/std/tests/Dev10_391723_bind_result_type/env.lst create mode 100644 tests/std/tests/Dev10_391723_bind_result_type/test.cpp create mode 100644 tests/std/tests/Dev10_414242_facet_bug_use_facet_ctype_char/env.lst create mode 100644 tests/std/tests/Dev10_414242_facet_bug_use_facet_ctype_char/test.cpp create mode 100644 tests/std/tests/Dev10_441756_function_reference_wrapper/env.lst create mode 100644 tests/std/tests/Dev10_441756_function_reference_wrapper/test.cpp create mode 100644 tests/std/tests/Dev10_445289_make_shared/env.lst create mode 100644 tests/std/tests/Dev10_445289_make_shared/test.cpp create mode 100644 tests/std/tests/Dev10_470547_facet_bug_stringstream/env.lst create mode 100644 tests/std/tests/Dev10_470547_facet_bug_stringstream/test.cpp create mode 100644 tests/std/tests/Dev10_482830_header_only_string/env.lst create mode 100644 tests/std/tests/Dev10_482830_header_only_string/test.cpp create mode 100644 tests/std/tests/Dev10_491486_floating_point_hash/env.lst create mode 100644 tests/std/tests/Dev10_491486_floating_point_hash/test.cpp create mode 100644 tests/std/tests/Dev10_492345_tr1_function_swap/env.lst create mode 100644 tests/std/tests/Dev10_492345_tr1_function_swap/test.cpp create mode 100644 tests/std/tests/Dev10_498944_enable_shared_from_this_auto_ptr/env.lst create mode 100644 tests/std/tests/Dev10_498944_enable_shared_from_this_auto_ptr/test.cpp create mode 100644 tests/std/tests/Dev10_500860_overloaded_address_of/env.lst create mode 100644 tests/std/tests/Dev10_500860_overloaded_address_of/test.cpp create mode 100644 tests/std/tests/Dev10_544258_heterogeneous_comparisons/env.lst create mode 100644 tests/std/tests/Dev10_544258_heterogeneous_comparisons/test.cpp create mode 100644 tests/std/tests/Dev10_555491_complex_linker_errors/env.lst create mode 100644 tests/std/tests/Dev10_555491_complex_linker_errors/test.cpp create mode 100644 tests/std/tests/Dev10_561430_list_and_tree_leaks/env.lst create mode 100644 tests/std/tests/Dev10_561430_list_and_tree_leaks/test.cpp create mode 100644 tests/std/tests/Dev10_562056_tree_leak/env.lst create mode 100644 tests/std/tests/Dev10_562056_tree_leak/test.cpp create mode 100644 tests/std/tests/Dev10_563443_empty_vector_begin_plus_zero/env.lst create mode 100644 tests/std/tests/Dev10_563443_empty_vector_begin_plus_zero/test.cpp create mode 100644 tests/std/tests/Dev10_567556_move_from_empty_list/env.lst create mode 100644 tests/std/tests/Dev10_567556_move_from_empty_list/test.cpp create mode 100644 tests/std/tests/Dev10_579381_vector_grow_to/env.lst create mode 100644 tests/std/tests/Dev10_579381_vector_grow_to/test.cpp create mode 100644 tests/std/tests/Dev10_590599_hash_string/env.lst create mode 100644 tests/std/tests/Dev10_590599_hash_string/test.cpp create mode 100644 tests/std/tests/Dev10_609053_ctype_char_table_size/env.lst create mode 100644 tests/std/tests/Dev10_609053_ctype_char_table_size/test.cpp create mode 100644 tests/std/tests/Dev10_617014_tuple_tie/env.lst create mode 100644 tests/std/tests/Dev10_617014_tuple_tie/test.cpp create mode 100644 tests/std/tests/Dev10_632876_regex_proxy/env.lst create mode 100644 tests/std/tests/Dev10_632876_regex_proxy/test.cpp create mode 100644 tests/std/tests/Dev10_635436_shared_ptr_reset/env.lst create mode 100644 tests/std/tests/Dev10_635436_shared_ptr_reset/test.cpp create mode 100644 tests/std/tests/Dev10_639436_const_map_at/env.lst create mode 100644 tests/std/tests/Dev10_639436_const_map_at/test.cpp create mode 100644 tests/std/tests/Dev10_646244_bad_alloc_message/env.lst create mode 100644 tests/std/tests/Dev10_646244_bad_alloc_message/test.cpp create mode 100644 tests/std/tests/Dev10_646556_construct_tuple_from_const/env.lst create mode 100644 tests/std/tests/Dev10_646556_construct_tuple_from_const/test.cpp create mode 100644 tests/std/tests/Dev10_654977_655012_shared_ptr_move/env.lst create mode 100644 tests/std/tests/Dev10_654977_655012_shared_ptr_move/test.cpp create mode 100644 tests/std/tests/Dev10_661739_tuple_copy_ctors/env.lst create mode 100644 tests/std/tests/Dev10_661739_tuple_copy_ctors/test.cpp create mode 100644 tests/std/tests/Dev10_682964_stable_sort_warnings/env.lst create mode 100644 tests/std/tests/Dev10_682964_stable_sort_warnings/test.cpp create mode 100644 tests/std/tests/Dev10_689595_back_inserter_vector_bool/env.lst create mode 100644 tests/std/tests/Dev10_689595_back_inserter_vector_bool/test.cpp create mode 100644 tests/std/tests/Dev10_709166_checked_and_unchecked_array_iterator/env.lst create mode 100644 tests/std/tests/Dev10_709166_checked_and_unchecked_array_iterator/test.cpp create mode 100644 tests/std/tests/Dev10_709168_marking_iterators_as_checked/env.lst create mode 100644 tests/std/tests/Dev10_709168_marking_iterators_as_checked/test.cpp create mode 100644 tests/std/tests/Dev10_722102_shared_ptr_nullptr/env.lst create mode 100644 tests/std/tests/Dev10_722102_shared_ptr_nullptr/test.cpp create mode 100644 tests/std/tests/Dev10_729003_bind_reference_wrapper/env.lst create mode 100644 tests/std/tests/Dev10_729003_bind_reference_wrapper/test.cpp create mode 100644 tests/std/tests/Dev10_766948_insert_ambiguity/env.lst create mode 100644 tests/std/tests/Dev10_766948_insert_ambiguity/test.cpp create mode 100644 tests/std/tests/Dev10_780098_movable_elements/env.lst create mode 100644 tests/std/tests/Dev10_780098_movable_elements/test.cpp create mode 100644 tests/std/tests/Dev10_783436_rvalue_string_plus/env.lst create mode 100644 tests/std/tests/Dev10_783436_rvalue_string_plus/test.cpp create mode 100644 tests/std/tests/Dev10_809142_copy_n_istream_iterator/env.lst create mode 100644 tests/std/tests/Dev10_809142_copy_n_istream_iterator/test.cpp create mode 100644 tests/std/tests/Dev10_814245_regex_character_class_crash/env.lst create mode 100644 tests/std/tests/Dev10_814245_regex_character_class_crash/test.cpp create mode 100644 tests/std/tests/Dev10_816787_swap_vector_bool_elements/env.lst create mode 100644 tests/std/tests/Dev10_816787_swap_vector_bool_elements/test.cpp create mode 100644 tests/std/tests/Dev10_847656_shared_ptr_is_convertible/env.lst create mode 100644 tests/std/tests/Dev10_847656_shared_ptr_is_convertible/test.cpp create mode 100644 tests/std/tests/Dev10_851347_weak_ptr_virtual_inheritance/env.lst create mode 100644 tests/std/tests/Dev10_851347_weak_ptr_virtual_inheritance/test.cpp create mode 100644 tests/std/tests/Dev10_860410_bitset_ctors/env.lst create mode 100644 tests/std/tests/Dev10_860410_bitset_ctors/test.cpp create mode 100644 tests/std/tests/Dev10_860421_deque_push_back_pop_front/env.lst create mode 100644 tests/std/tests/Dev10_860421_deque_push_back_pop_front/test.cpp create mode 100644 tests/std/tests/Dev10_881629_vector_erase_return_value/env.lst create mode 100644 tests/std/tests/Dev10_881629_vector_erase_return_value/test.cpp create mode 100644 tests/std/tests/Dev10_904413_moved_from_function_should_be_empty/env.lst create mode 100644 tests/std/tests/Dev10_904413_moved_from_function_should_be_empty/test.cpp create mode 100644 tests/std/tests/Dev10_905461_is_sorted_until/env.lst create mode 100644 tests/std/tests/Dev10_905461_is_sorted_until/test.cpp create mode 100644 tests/std/tests/Dev10_908702_string_memory_leak/env.lst create mode 100644 tests/std/tests/Dev10_908702_string_memory_leak/test.cpp create mode 100644 tests/std/tests/Dev10_909646_stringstream_vd2/env.lst create mode 100644 tests/std/tests/Dev10_909646_stringstream_vd2/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_dual_range_algorithms/env.lst create mode 100644 tests/std/tests/Dev11_0000000_dual_range_algorithms/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_function_crashes/env.lst create mode 100644 tests/std/tests/Dev11_0000000_function_crashes/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_include_each_header_alone/env.lst create mode 100644 tests/std/tests/Dev11_0000000_include_each_header_alone/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_null_forward_iterators/env.lst create mode 100644 tests/std/tests/Dev11_0000000_null_forward_iterators/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_quoted/env.lst create mode 100644 tests/std/tests/Dev11_0000000_quoted/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_rotate_test/env.lst create mode 100644 tests/std/tests/Dev11_0000000_rotate_test/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_tuple_cat/env.lst create mode 100644 tests/std/tests/Dev11_0000000_tuple_cat/test.cpp create mode 100644 tests/std/tests/Dev11_0000000_user_defined_literals/env.lst create mode 100644 tests/std/tests/Dev11_0000000_user_defined_literals/test.cpp create mode 100644 tests/std/tests/Dev11_0019127_singular_iterators/env.lst create mode 100644 tests/std/tests/Dev11_0019127_singular_iterators/test.cpp create mode 100644 tests/std/tests/Dev11_0091392_string_erase_resize_perf/env.lst create mode 100644 tests/std/tests/Dev11_0091392_string_erase_resize_perf/test.cpp create mode 100644 tests/std/tests/Dev11_0133625_locale0_implib_cpp/env.lst create mode 100644 tests/std/tests/Dev11_0133625_locale0_implib_cpp/test.cpp create mode 100644 tests/std/tests/Dev11_0135139_vector_bool_equality_perf/env.lst create mode 100644 tests/std/tests/Dev11_0135139_vector_bool_equality_perf/test.cpp create mode 100644 tests/std/tests/Dev11_0235721_async_and_packaged_task/env.lst create mode 100644 tests/std/tests/Dev11_0235721_async_and_packaged_task/test.cpp create mode 100644 tests/std/tests/Dev11_0253803_debug_pointer/env.lst create mode 100644 tests/std/tests/Dev11_0253803_debug_pointer/test.cpp create mode 100644 tests/std/tests/Dev11_0272959_make_signed/env.lst create mode 100644 tests/std/tests/Dev11_0272959_make_signed/test.cpp create mode 100644 tests/std/tests/Dev11_0289403_partition_point_complexity/env.lst create mode 100644 tests/std/tests/Dev11_0289403_partition_point_complexity/test.cpp create mode 100644 tests/std/tests/Dev11_0299014_exception_ptr_requirements/env.lst create mode 100644 tests/std/tests/Dev11_0299014_exception_ptr_requirements/test.cpp create mode 100644 tests/std/tests/Dev11_0302476_pair_move/env.lst create mode 100644 tests/std/tests/Dev11_0302476_pair_move/test.cpp create mode 100644 tests/std/tests/Dev11_0314451_make_pair_make_tuple/env.lst create mode 100644 tests/std/tests/Dev11_0314451_make_pair_make_tuple/test.cpp create mode 100644 tests/std/tests/Dev11_0316853_find_memchr_optimization/env.lst create mode 100644 tests/std/tests/Dev11_0316853_find_memchr_optimization/test.cpp create mode 100644 tests/std/tests/Dev11_0343056_pair_tuple_ctor_sfinae/env.lst create mode 100644 tests/std/tests/Dev11_0343056_pair_tuple_ctor_sfinae/test.cpp create mode 100644 tests/std/tests/Dev11_0376122_grand_theft_bind/env.lst create mode 100644 tests/std/tests/Dev11_0376122_grand_theft_bind/test.cpp create mode 100644 tests/std/tests/Dev11_0377755_thread_ctor_move_only_types/env.lst create mode 100644 tests/std/tests/Dev11_0377755_thread_ctor_move_only_types/test.cpp create mode 100644 tests/std/tests/Dev11_0387701_container_equality/env.lst create mode 100644 tests/std/tests/Dev11_0387701_container_equality/test.cpp create mode 100644 tests/std/tests/Dev11_0417110_nullptr_t_is_scalar/env.lst create mode 100644 tests/std/tests/Dev11_0417110_nullptr_t_is_scalar/test.cpp create mode 100644 tests/std/tests/Dev11_0435439_call_once_deadlock/env.lst create mode 100644 tests/std/tests/Dev11_0435439_call_once_deadlock/test.cpp create mode 100644 tests/std/tests/Dev11_0437519_container_behavior/env.lst create mode 100644 tests/std/tests/Dev11_0437519_container_behavior/test.cpp create mode 100644 tests/std/tests/Dev11_0437519_container_requirements/env.lst create mode 100644 tests/std/tests/Dev11_0437519_container_requirements/test.cpp create mode 100644 tests/std/tests/Dev11_0447546_facet_allocation/env.lst create mode 100644 tests/std/tests/Dev11_0447546_facet_allocation/test.cpp create mode 100644 tests/std/tests/Dev11_0453373_codecvt_compiles/env.lst create mode 100644 tests/std/tests/Dev11_0453373_codecvt_compiles/test.cpp create mode 100644 tests/std/tests/Dev11_0483851_vector_debug_allocator_use/env.lst create mode 100644 tests/std/tests/Dev11_0483851_vector_debug_allocator_use/test.cpp create mode 100644 tests/std/tests/Dev11_0485243_condition_variable_crash/env.lst create mode 100644 tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp create mode 100644 tests/std/tests/Dev11_0493504_error_category_lifetime/env.lst create mode 100644 tests/std/tests/Dev11_0493504_error_category_lifetime/test.cpp create mode 100644 tests/std/tests/Dev11_0494593_time_put_wchar_t/env.lst create mode 100644 tests/std/tests/Dev11_0494593_time_put_wchar_t/test.cpp create mode 100644 tests/std/tests/Dev11_0496153_locale_ctor/env.lst create mode 100644 tests/std/tests/Dev11_0496153_locale_ctor/test.cpp create mode 100644 tests/std/tests/Dev11_0532622_minmax_element/env.lst create mode 100644 tests/std/tests/Dev11_0532622_minmax_element/test.cpp create mode 100644 tests/std/tests/Dev11_0535636_functional_overhaul/env.lst create mode 100644 tests/std/tests/Dev11_0535636_functional_overhaul/test.cpp create mode 100644 tests/std/tests/Dev11_0555154_system_clock_to_time_t/env.lst create mode 100644 tests/std/tests/Dev11_0555154_system_clock_to_time_t/test.cpp create mode 100644 tests/std/tests/Dev11_0577418_random_seed_0/env.lst create mode 100644 tests/std/tests/Dev11_0577418_random_seed_0/test.cpp create mode 100644 tests/std/tests/Dev11_0579795_inplace_merge_out_of_memory/env.lst create mode 100644 tests/std/tests/Dev11_0579795_inplace_merge_out_of_memory/test.cpp create mode 100644 tests/std/tests/Dev11_0607540_pair_tuple_rvalue_references/env.lst create mode 100644 tests/std/tests/Dev11_0607540_pair_tuple_rvalue_references/test.cpp create mode 100644 tests/std/tests/Dev11_0617384_empty_std_function/env.lst create mode 100644 tests/std/tests/Dev11_0617384_empty_std_function/test.cpp create mode 100644 tests/std/tests/Dev11_0653897_codecvt_partial/env.lst create mode 100644 tests/std/tests/Dev11_0653897_codecvt_partial/test.cpp create mode 100644 tests/std/tests/Dev11_0671816_list_splice/env.lst create mode 100644 tests/std/tests/Dev11_0671816_list_splice/test.cpp create mode 100644 tests/std/tests/Dev11_0696045_future_wait_for/env.lst create mode 100644 tests/std/tests/Dev11_0696045_future_wait_for/test.cpp create mode 100644 tests/std/tests/Dev11_0704582_ratio/env.lst create mode 100644 tests/std/tests/Dev11_0704582_ratio/test.cpp create mode 100644 tests/std/tests/Dev11_0732166_unordered_strong_guarantee/env.lst create mode 100644 tests/std/tests/Dev11_0732166_unordered_strong_guarantee/test.cpp create mode 100644 tests/std/tests/Dev11_0748972_function_crash_out_of_memory/env.lst create mode 100644 tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp create mode 100644 tests/std/tests/Dev11_0823534_transparent_lookup/env.lst create mode 100644 tests/std/tests/Dev11_0823534_transparent_lookup/test.cpp create mode 100644 tests/std/tests/Dev11_0835323_to_string/env.lst create mode 100644 tests/std/tests/Dev11_0835323_to_string/test.cpp create mode 100644 tests/std/tests/Dev11_0836436_get_time/env.lst create mode 100644 tests/std/tests/Dev11_0836436_get_time/test.cpp create mode 100644 tests/std/tests/Dev11_0845312_comprehensive_floating_point/env.lst create mode 100644 tests/std/tests/Dev11_0845312_comprehensive_floating_point/test.cpp create mode 100644 tests/std/tests/Dev11_0863628_atomic_compare_exchange/env.lst create mode 100644 tests/std/tests/Dev11_0863628_atomic_compare_exchange/test.cpp create mode 100644 tests/std/tests/Dev11_0920385_list_sort_allocator/env.lst create mode 100644 tests/std/tests/Dev11_0920385_list_sort_allocator/test.cpp create mode 100644 tests/std/tests/Dev11_1003120_search_test/env.lst create mode 100644 tests/std/tests/Dev11_1003120_search_test/test.cpp create mode 100644 tests/std/tests/Dev11_1066589_shared_ptr_atomic_deadlock/env.lst create mode 100644 tests/std/tests/Dev11_1066589_shared_ptr_atomic_deadlock/test.cpp create mode 100644 tests/std/tests/Dev11_1066931_filesystem_rename_noop/env.lst create mode 100644 tests/std/tests/Dev11_1066931_filesystem_rename_noop/test.cpp create mode 100644 tests/std/tests/Dev11_1074023_constexpr/env.lst create mode 100644 tests/std/tests/Dev11_1074023_constexpr/test.cpp create mode 100644 tests/std/tests/Dev11_1086953_call_once_overhaul/env.lst create mode 100644 tests/std/tests/Dev11_1086953_call_once_overhaul/test.cpp create mode 100644 tests/std/tests/Dev11_1114006_condition_variable_pred/env.lst create mode 100644 tests/std/tests/Dev11_1114006_condition_variable_pred/test.cpp create mode 100644 tests/std/tests/Dev11_1127004_future_has_exceptions_0/env.lst create mode 100644 tests/std/tests/Dev11_1127004_future_has_exceptions_0/test.cpp create mode 100644 tests/std/tests/Dev11_1131212_uncaught_exceptions/env.lst create mode 100644 tests/std/tests/Dev11_1131212_uncaught_exceptions/test.cpp create mode 100644 tests/std/tests/Dev11_1137366_nested_exception/env.lst create mode 100644 tests/std/tests/Dev11_1137366_nested_exception/test.cpp create mode 100644 tests/std/tests/Dev11_1140665_unique_ptr_array_conversions/env.lst create mode 100644 tests/std/tests/Dev11_1140665_unique_ptr_array_conversions/test.cpp create mode 100644 tests/std/tests/Dev11_1150223_shared_mutex/env.lst create mode 100644 tests/std/tests/Dev11_1150223_shared_mutex/test.cpp create mode 100644 tests/std/tests/Dev11_1158803_regex_thread_safety/env.lst create mode 100644 tests/std/tests/Dev11_1158803_regex_thread_safety/test.cpp create mode 100644 tests/std/tests/Dev11_1180290_filesystem_error_code/env.lst create mode 100644 tests/std/tests/Dev11_1180290_filesystem_error_code/test.cpp create mode 100644 tests/std/tests/GH_000457_system_error_message/env.lst create mode 100644 tests/std/tests/GH_000457_system_error_message/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_adjacent_difference/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_adjacent_difference/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_adjacent_find/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_adjacent_find/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_all_of/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_all_of/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_count/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_count/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_equal/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_equal/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_exclusive_scan/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_exclusive_scan/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_find/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_find/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_find_end/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_find_end/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_find_first_of/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_find_first_of/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_for_each/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_for_each/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_inclusive_scan/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_inclusive_scan/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_is_heap/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_is_heap/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_is_partitioned/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_is_partitioned/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_is_sorted/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_is_sorted/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_mismatch/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_mismatch/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_partition/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_partition/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_reduce/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_reduce/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_remove/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_remove/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_replace/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_replace/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_search/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_search/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_search_n/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_search_n/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_set_difference/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_set_difference/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_set_intersection/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_set_intersection/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_sort/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_sort/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_stable_sort/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_stable_sort/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform_exclusive_scan/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform_exclusive_scan/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform_inclusive_scan/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform_inclusive_scan/test.cpp create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform_reduce/env.lst create mode 100644 tests/std/tests/P0024R2_parallel_algorithms_transform_reduce/test.cpp create mode 100644 tests/std/tests/P0035R4_over_aligned_allocation/env.lst create mode 100644 tests/std/tests/P0035R4_over_aligned_allocation/test.cpp create mode 100644 tests/std/tests/P0040R3_extending_memory_management_tools/env.lst create mode 100644 tests/std/tests/P0040R3_extending_memory_management_tools/test.cpp create mode 100644 tests/std/tests/P0067R5_charconv/double_fixed_precision_to_chars_test_cases_1.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_fixed_precision_to_chars_test_cases_2.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_fixed_precision_to_chars_test_cases_3.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_fixed_precision_to_chars_test_cases_4.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_from_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_general_precision_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_hex_precision_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_scientific_precision_to_chars_test_cases_1.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_scientific_precision_to_chars_test_cases_2.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_scientific_precision_to_chars_test_cases_3.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_scientific_precision_to_chars_test_cases_4.hpp create mode 100644 tests/std/tests/P0067R5_charconv/double_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/env.lst create mode 100644 tests/std/tests/P0067R5_charconv/float_fixed_precision_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/float_from_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/float_general_precision_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/float_hex_precision_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/float_scientific_precision_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/float_to_chars_test_cases.hpp create mode 100644 tests/std/tests/P0067R5_charconv/test.cpp create mode 100644 tests/std/tests/P0067R5_charconv/test.hpp create mode 100644 tests/std/tests/P0083R3_splicing_maps_and_sets/env.lst create mode 100644 tests/std/tests/P0083R3_splicing_maps_and_sets/test.cpp create mode 100644 tests/std/tests/P0088R3_variant/env.lst create mode 100644 tests/std/tests/P0088R3_variant/test.cpp create mode 100644 tests/std/tests/P0092R1_polishing_chrono/env.lst create mode 100644 tests/std/tests/P0092R1_polishing_chrono/test.cpp create mode 100644 tests/std/tests/P0122R7_span/env.lst create mode 100644 tests/std/tests/P0122R7_span/test.cpp create mode 100644 tests/std/tests/P0122R7_span_death/env.lst create mode 100644 tests/std/tests/P0122R7_span_death/test.cpp create mode 100644 tests/std/tests/P0137R1_launder/env.lst create mode 100644 tests/std/tests/P0137R1_launder/test.cpp create mode 100644 tests/std/tests/P0156R2_scoped_lock/env.lst create mode 100644 tests/std/tests/P0156R2_scoped_lock/test.cpp create mode 100644 tests/std/tests/P0202R3_constexpr_algorithm_and_exchange/env.lst create mode 100644 tests/std/tests/P0202R3_constexpr_algorithm_and_exchange/test.cpp create mode 100644 tests/std/tests/P0218R1_filesystem/env.lst create mode 100644 tests/std/tests/P0218R1_filesystem/test.cpp create mode 100644 tests/std/tests/P0220R1_any/env.lst create mode 100644 tests/std/tests/P0220R1_any/test.cpp create mode 100644 tests/std/tests/P0220R1_optional/env.lst create mode 100644 tests/std/tests/P0220R1_optional/test.cpp create mode 100644 tests/std/tests/P0220R1_polymorphic_memory_resources/env.lst create mode 100644 tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp create mode 100644 tests/std/tests/P0220R1_sample/adapterator.hpp create mode 100644 tests/std/tests/P0220R1_sample/env.lst create mode 100644 tests/std/tests/P0220R1_sample/test.cpp create mode 100644 tests/std/tests/P0220R1_searchers/env.lst create mode 100644 tests/std/tests/P0220R1_searchers/test.cpp create mode 100644 tests/std/tests/P0220R1_string_view/env.lst create mode 100644 tests/std/tests/P0220R1_string_view/test.cpp create mode 100644 tests/std/tests/P0325R4_to_array/env.lst create mode 100644 tests/std/tests/P0325R4_to_array/test.cpp create mode 100644 tests/std/tests/P0356R5_bind_front/env.lst create mode 100644 tests/std/tests/P0356R5_bind_front/test.cpp create mode 100644 tests/std/tests/P0357R3_supporting_incomplete_types_in_reference_wrapper/env.lst create mode 100644 tests/std/tests/P0357R3_supporting_incomplete_types_in_reference_wrapper/test.cpp create mode 100644 tests/std/tests/P0414R2_shared_ptr_for_arrays/env.lst create mode 100644 tests/std/tests/P0414R2_shared_ptr_for_arrays/test.cpp create mode 100644 tests/std/tests/P0426R1_constexpr_char_traits/env.lst create mode 100644 tests/std/tests/P0426R1_constexpr_char_traits/test.cpp create mode 100644 tests/std/tests/P0433R2_deduction_guides/env.lst create mode 100644 tests/std/tests/P0433R2_deduction_guides/test.cpp create mode 100644 tests/std/tests/P0487R1_fixing_operator_shl_basic_istream_char_pointer/env.lst create mode 100644 tests/std/tests/P0487R1_fixing_operator_shl_basic_istream_char_pointer/test.cpp create mode 100644 tests/std/tests/P0513R0_poisoning_the_hash/env.lst create mode 100644 tests/std/tests/P0513R0_poisoning_the_hash/test.cpp create mode 100644 tests/std/tests/P0553R4_bit_rotating_and_counting_functions/env.lst create mode 100644 tests/std/tests/P0553R4_bit_rotating_and_counting_functions/test.cpp create mode 100644 tests/std/tests/P0556R3_bit_ispow2_ceil2_floor2_log2p1/env.lst create mode 100644 tests/std/tests/P0556R3_bit_ispow2_ceil2_floor2_log2p1/test.cpp create mode 100644 tests/std/tests/P0595R2_is_constant_evaluated/env.lst create mode 100644 tests/std/tests/P0595R2_is_constant_evaluated/test.cpp create mode 100644 tests/std/tests/P0607R0_inline_variables/env.lst create mode 100644 tests/std/tests/P0607R0_inline_variables/test.cpp create mode 100644 tests/std/tests/P0607R0_inline_variables/test2.cpp create mode 100644 tests/std/tests/P0616R0_using_move_in_numeric/env.lst create mode 100644 tests/std/tests/P0616R0_using_move_in_numeric/test.cpp create mode 100644 tests/std/tests/P0631R8_numbers_math_constants/env.lst create mode 100644 tests/std/tests/P0631R8_numbers_math_constants/test.cpp create mode 100644 tests/std/tests/P0674R1_make_shared_for_arrays/env.lst create mode 100644 tests/std/tests/P0674R1_make_shared_for_arrays/test.cpp create mode 100644 tests/std/tests/P0758R1_is_nothrow_convertible/env.lst create mode 100644 tests/std/tests/P0758R1_is_nothrow_convertible/test.cpp create mode 100644 tests/std/tests/P0768R1_spaceship_operator/env.lst create mode 100644 tests/std/tests/P0768R1_spaceship_operator/test.cpp create mode 100644 tests/std/tests/P0769R2_shift_left_shift_right/env.lst create mode 100644 tests/std/tests/P0769R2_shift_left_shift_right/test.cpp create mode 100644 tests/std/tests/P0811R3_midpoint_lerp/env.lst create mode 100644 tests/std/tests/P0811R3_midpoint_lerp/test.cpp create mode 100644 tests/std/tests/P0896R4_ranges_iterator_machinery/env.lst create mode 100644 tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp create mode 100644 tests/std/tests/P0896R4_ranges_range_machinery/env.lst create mode 100644 tests/std/tests/P0896R4_ranges_range_machinery/test.cpp create mode 100644 tests/std/tests/P0896R4_ranges_to_address/env.lst create mode 100644 tests/std/tests/P0896R4_ranges_to_address/test.cpp create mode 100644 tests/std/tests/P0898R3_concepts/env.lst create mode 100644 tests/std/tests/P0898R3_concepts/invocable_cc.hpp create mode 100644 tests/std/tests/P0898R3_concepts/test.cpp create mode 100644 tests/std/tests/P0898R3_identity/env.lst create mode 100644 tests/std/tests/P0898R3_identity/test.cpp create mode 100644 tests/std/tests/P0919R3_heterogeneous_unordered_lookup/env.lst create mode 100644 tests/std/tests/P0919R3_heterogeneous_unordered_lookup/test.cpp create mode 100644 tests/std/tests/P0966R1_string_reserve_should_not_shrink/env.lst create mode 100644 tests/std/tests/P0966R1_string_reserve_should_not_shrink/test.cpp create mode 100644 tests/std/tests/P1165R1_consistently_propagating_stateful_allocators/env.lst create mode 100644 tests/std/tests/P1165R1_consistently_propagating_stateful_allocators/test.cpp create mode 100644 tests/std/tests/P1423R3_char8_t_remediation/env.lst create mode 100644 tests/std/tests/P1423R3_char8_t_remediation/test.cpp create mode 100644 tests/std/tests/P1645R1_constexpr_numeric/env.lst create mode 100644 tests/std/tests/P1645R1_constexpr_numeric/test.cpp create mode 100644 tests/std/tests/VSO_0000000_allocator_propagation/env.lst create mode 100644 tests/std/tests/VSO_0000000_allocator_propagation/test.cpp create mode 100644 tests/std/tests/VSO_0000000_any_calling_conventions/a.cpp create mode 100644 tests/std/tests/VSO_0000000_any_calling_conventions/ab.hpp create mode 100644 tests/std/tests/VSO_0000000_any_calling_conventions/b.cpp create mode 100644 tests/std/tests/VSO_0000000_any_calling_conventions/custombuild.pl create mode 100644 tests/std/tests/VSO_0000000_any_calling_conventions/env.lst create mode 100644 tests/std/tests/VSO_0000000_c_math_functions/both.cpp create mode 100644 tests/std/tests/VSO_0000000_c_math_functions/cmath.cpp create mode 100644 tests/std/tests/VSO_0000000_c_math_functions/cstdlib.cpp create mode 100644 tests/std/tests/VSO_0000000_c_math_functions/env.lst create mode 100644 tests/std/tests/VSO_0000000_c_math_functions/type_asserts.hpp create mode 100644 tests/std/tests/VSO_0000000_condition_variable_any_exceptions/env.lst create mode 100644 tests/std/tests/VSO_0000000_condition_variable_any_exceptions/test.cpp create mode 100644 tests/std/tests/VSO_0000000_container_allocator_constructors/env.lst create mode 100644 tests/std/tests/VSO_0000000_container_allocator_constructors/test.cpp create mode 100644 tests/std/tests/VSO_0000000_exception_ptr_rethrow_seh/env.lst create mode 100644 tests/std/tests/VSO_0000000_exception_ptr_rethrow_seh/test.cpp create mode 100644 tests/std/tests/VSO_0000000_fancy_pointers/env.lst create mode 100644 tests/std/tests/VSO_0000000_fancy_pointers/test.cpp create mode 100644 tests/std/tests/VSO_0000000_has_static_rtti/env.lst create mode 100644 tests/std/tests/VSO_0000000_has_static_rtti/test.cpp create mode 100644 tests/std/tests/VSO_0000000_initialize_everything/env.lst create mode 100644 tests/std/tests/VSO_0000000_initialize_everything/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_16_difference_type_1/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_16_difference_type_1/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_16_difference_type_2/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_16_difference_type_2/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_32_difference_type_1/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_32_difference_type_1/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_32_difference_type_2/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_32_difference_type_2/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_64_difference_type_1/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_64_difference_type_1/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_64_difference_type_2/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_64_difference_type_2/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_int_1/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_int_1/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_int_2/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_int_2/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_nontrivial_1/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_nontrivial_1/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_nontrivial_2/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_algorithms_nontrivial_2/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_containers/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_containers/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_cvt/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_cvt/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_iterators_misc/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.cpp create mode 100644 tests/std/tests/VSO_0000000_instantiate_type_traits/env.lst create mode 100644 tests/std/tests/VSO_0000000_instantiate_type_traits/test.cpp create mode 100644 tests/std/tests/VSO_0000000_list_iterator_debugging/env.lst create mode 100644 tests/std/tests/VSO_0000000_list_iterator_debugging/test.cpp create mode 100644 tests/std/tests/VSO_0000000_list_unique_self_reference/env.lst create mode 100644 tests/std/tests/VSO_0000000_list_unique_self_reference/test.cpp create mode 100644 tests/std/tests/VSO_0000000_matching_npos_address/a.cpp create mode 100644 tests/std/tests/VSO_0000000_matching_npos_address/env.lst create mode 100644 tests/std/tests/VSO_0000000_matching_npos_address/main.cpp create mode 100644 tests/std/tests/VSO_0000000_more_pair_tuple_sfinae/env.lst create mode 100644 tests/std/tests/VSO_0000000_more_pair_tuple_sfinae/test.cpp create mode 100644 tests/std/tests/VSO_0000000_nullptr_stream_out/env.lst create mode 100644 tests/std/tests/VSO_0000000_nullptr_stream_out/test.cpp create mode 100644 tests/std/tests/VSO_0000000_oss_workarounds/env.lst create mode 100644 tests/std/tests/VSO_0000000_oss_workarounds/test.cpp create mode 100644 tests/std/tests/VSO_0000000_path_stream_parameter/env.lst create mode 100644 tests/std/tests/VSO_0000000_path_stream_parameter/test.cpp create mode 100644 tests/std/tests/VSO_0000000_regex_interface/env.lst create mode 100644 tests/std/tests/VSO_0000000_regex_interface/test.cpp create mode 100644 tests/std/tests/VSO_0000000_regex_use/env.lst create mode 100644 tests/std/tests/VSO_0000000_regex_use/test.cpp create mode 100644 tests/std/tests/VSO_0000000_strengthened_noexcept/env.lst create mode 100644 tests/std/tests/VSO_0000000_strengthened_noexcept/test.cpp create mode 100644 tests/std/tests/VSO_0000000_string_view_idl/env.lst create mode 100644 tests/std/tests/VSO_0000000_string_view_idl/test.cpp create mode 100644 tests/std/tests/VSO_0000000_type_traits/env.lst create mode 100644 tests/std/tests/VSO_0000000_type_traits/test.cpp create mode 100644 tests/std/tests/VSO_0000000_vector_algorithms/env.lst create mode 100644 tests/std/tests/VSO_0000000_vector_algorithms/test.cpp create mode 100644 tests/std/tests/VSO_0000000_wcfb01_idempotent_container_destructors/env.lst create mode 100644 tests/std/tests/VSO_0000000_wcfb01_idempotent_container_destructors/test.cpp create mode 100644 tests/std/tests/VSO_0000000_wchar_t_filebuf_xsmeown/env.lst create mode 100644 tests/std/tests/VSO_0000000_wchar_t_filebuf_xsmeown/test.cpp create mode 100644 tests/std/tests/VSO_0095468_clr_exception_ptr_bad_alloc/env.lst create mode 100644 tests/std/tests/VSO_0095468_clr_exception_ptr_bad_alloc/test.cpp create mode 100644 tests/std/tests/VSO_0095837_current_exception_dtor/env.lst create mode 100644 tests/std/tests/VSO_0095837_current_exception_dtor/test.cpp create mode 100644 tests/std/tests/VSO_0099869_pow_float_overflow/env.lst create mode 100644 tests/std/tests/VSO_0099869_pow_float_overflow/test.cpp create mode 100644 tests/std/tests/VSO_0102478_moving_allocators/env.lst create mode 100644 tests/std/tests/VSO_0102478_moving_allocators/test.cpp create mode 100644 tests/std/tests/VSO_0104705_throwing_copy_in_current_exception/env.lst create mode 100644 tests/std/tests/VSO_0104705_throwing_copy_in_current_exception/test.cpp create mode 100644 tests/std/tests/VSO_0104705_throwing_copy_in_current_exception_seh/env.lst create mode 100644 tests/std/tests/VSO_0104705_throwing_copy_in_current_exception_seh/test.cpp create mode 100644 tests/std/tests/VSO_0105317_expression_sfinae/env.lst create mode 100644 tests/std/tests/VSO_0105317_expression_sfinae/test.cpp create mode 100644 tests/std/tests/VSO_0118461_min_max_noexcept/env.lst create mode 100644 tests/std/tests/VSO_0118461_min_max_noexcept/test.cpp create mode 100644 tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/env.lst create mode 100644 tests/std/tests/VSO_0121275_filesystem_canonical_should_handle_many_double_dots/test.cpp create mode 100644 tests/std/tests/VSO_0121440_is_iterator_iterator_traits/env.lst create mode 100644 tests/std/tests/VSO_0121440_is_iterator_iterator_traits/test.cpp create mode 100644 tests/std/tests/VSO_0131167_associative_emplacement_allocations/env.lst create mode 100644 tests/std/tests/VSO_0131167_associative_emplacement_allocations/test.cpp create mode 100644 tests/std/tests/VSO_0135428_custom_char_traits_string/env.lst create mode 100644 tests/std/tests/VSO_0135428_custom_char_traits_string/test.cpp create mode 100644 tests/std/tests/VSO_0144114_sleep_until/env.lst create mode 100644 tests/std/tests/VSO_0144114_sleep_until/test.cpp create mode 100644 tests/std/tests/VSO_0144294_unordered_map_max_bucket_count/env.lst create mode 100644 tests/std/tests/VSO_0144294_unordered_map_max_bucket_count/test.cpp create mode 100644 tests/std/tests/VSO_0149983_system_error_broken_pipe/env.lst create mode 100644 tests/std/tests/VSO_0149983_system_error_broken_pipe/test.cpp create mode 100644 tests/std/tests/VSO_0157762_feature_test_macros/env.lst create mode 100644 tests/std/tests/VSO_0157762_feature_test_macros/test.cpp create mode 100644 tests/std/tests/VSO_0174871_string_replace/env.lst create mode 100644 tests/std/tests/VSO_0174871_string_replace/test.cpp create mode 100644 tests/std/tests/VSO_0180466_algorithm_overhauls/env.lst create mode 100644 tests/std/tests/VSO_0180466_algorithm_overhauls/test.cpp create mode 100644 tests/std/tests/VSO_0180469_fill_family/env.lst create mode 100644 tests/std/tests/VSO_0180469_fill_family/test.cpp create mode 100644 tests/std/tests/VSO_0180469_ptr_cat/env.lst create mode 100644 tests/std/tests/VSO_0180469_ptr_cat/test.cpp create mode 100644 tests/std/tests/VSO_0191296_allocator_construct/env.lst create mode 100644 tests/std/tests/VSO_0191296_allocator_construct/test.cpp create mode 100644 tests/std/tests/VSO_0204655_heap_algorithms_integer_overflow/env.lst create mode 100644 tests/std/tests/VSO_0204655_heap_algorithms_integer_overflow/test.cpp create mode 100644 tests/std/tests/VSO_0224478_scoped_allocator/env.lst create mode 100644 tests/std/tests/VSO_0224478_scoped_allocator/test.cpp create mode 100644 tests/std/tests/VSO_0226079_mutex/env.lst create mode 100644 tests/std/tests/VSO_0226079_mutex/test.cpp create mode 100644 tests/std/tests/VSO_0234888_num_get_overflows/env.lst create mode 100644 tests/std/tests/VSO_0234888_num_get_overflows/test.cpp create mode 100644 tests/std/tests/VSO_0299624_checked_array_iterator_idl/env.lst create mode 100644 tests/std/tests/VSO_0299624_checked_array_iterator_idl/test.cpp create mode 100644 tests/std/tests/VSO_0397980_codecvt_length/env.lst create mode 100644 tests/std/tests/VSO_0397980_codecvt_length/test.cpp create mode 100644 tests/std/tests/VSO_0429900_fast_debug_range_based_for/env.lst create mode 100644 tests/std/tests/VSO_0429900_fast_debug_range_based_for/test.cpp create mode 100644 tests/std/tests/VSO_0474901_shift_jis_codecvt/env.lst create mode 100644 tests/std/tests/VSO_0474901_shift_jis_codecvt/test.cpp create mode 100644 tests/std/tests/VSO_0493909_is_aggregate/env.lst create mode 100644 tests/std/tests/VSO_0493909_is_aggregate/test.cpp create mode 100644 tests/std/tests/VSO_0512710_terminate_current_exception_from_noexcept_function/env.lst create mode 100644 tests/std/tests/VSO_0512710_terminate_current_exception_from_noexcept_function/test.cpp create mode 100644 tests/std/tests/VSO_0512710_terminate_current_exception_from_noexcept_function_2/env.lst create mode 100644 tests/std/tests/VSO_0512710_terminate_current_exception_from_noexcept_function_2/test.cpp create mode 100644 tests/std/tests/VSO_0512710_terminate_current_exception_from_unwind/env.lst create mode 100644 tests/std/tests/VSO_0512710_terminate_current_exception_from_unwind/test.cpp create mode 100644 tests/std/tests/VSO_0527559_pragma_managed/env.lst create mode 100644 tests/std/tests/VSO_0527559_pragma_managed/test.cpp create mode 100644 tests/std/tests/VSO_0575109_string_ambiguous_overloads/env.lst create mode 100644 tests/std/tests/VSO_0575109_string_ambiguous_overloads/test.cpp create mode 100644 tests/std/tests/VSO_0599804_seekg_zero/env.lst create mode 100644 tests/std/tests/VSO_0599804_seekg_zero/test.cpp create mode 100644 tests/std/tests/VSO_0644691_utf_8_codecvt/env.lst create mode 100644 tests/std/tests/VSO_0644691_utf_8_codecvt/test.cpp create mode 100644 tests/std/tests/VSO_0663136_string_includes_cctype/env.lst create mode 100644 tests/std/tests/VSO_0663136_string_includes_cctype/test.cpp create mode 100644 tests/std/tests/VSO_0664587_lcg_divide_by_zero/env.lst create mode 100644 tests/std/tests/VSO_0664587_lcg_divide_by_zero/test.cpp create mode 100644 tests/std/tests/VSO_0677157_flist_merge_edge_cases/env.lst create mode 100644 tests/std/tests/VSO_0677157_flist_merge_edge_cases/test.cpp create mode 100644 tests/std/tests/VSO_0735700_fstream_read_over_4k/env.lst create mode 100644 tests/std/tests/VSO_0735700_fstream_read_over_4k/test.cpp create mode 100644 tests/std/tests/VSO_0736657_unordered_assign_rehash/env.lst create mode 100644 tests/std/tests/VSO_0736657_unordered_assign_rehash/test.cpp create mode 100644 tests/std/tests/VSO_0744055_atomic_load_8_bytes_readonly/env.lst create mode 100644 tests/std/tests/VSO_0744055_atomic_load_8_bytes_readonly/test.cpp create mode 100644 tests/std/tests/VSO_0792651_unordered_set_rehash_invalidates_key/env.lst create mode 100644 tests/std/tests/VSO_0792651_unordered_set_rehash_invalidates_key/test.cpp create mode 100644 tests/std/tests/VSO_0830211_container_debugging_range_checks/env.lst create mode 100644 tests/std/tests/VSO_0830211_container_debugging_range_checks/test.cpp create mode 100644 tests/std/tests/VSO_0849827_multicontainer_emplace_hint_position/env.lst create mode 100644 tests/std/tests/VSO_0849827_multicontainer_emplace_hint_position/test.cpp create mode 100644 tests/std/tests/VSO_0938757_attribute_order/env.lst create mode 100644 tests/std/tests/VSO_0938757_attribute_order/test.cpp create mode 100644 tests/std/tests/VSO_0961751_hash_range_erase/env.lst create mode 100644 tests/std/tests/VSO_0961751_hash_range_erase/test.cpp create mode 100644 tests/std/tests/VSO_0971246_legacy_await_headers/env.lst create mode 100644 tests/std/tests/VSO_0971246_legacy_await_headers/test.cpp create mode 100644 tests/std/tests/callconv_matrix.lst create mode 100644 tests/std/tests/clr_matrix.lst create mode 100644 tests/std/tests/concepts_matrix.lst create mode 100644 tests/std/tests/eha_matrix.lst create mode 100644 tests/std/tests/fast_matrix.lst create mode 100644 tests/std/tests/impure_matrix.lst create mode 100644 tests/std/tests/include_each_header_alone_matrix.lst create mode 100644 tests/std/tests/locale0_implib_cpp_matrix.lst create mode 100644 tests/std/tests/native_17_matrix.lst create mode 100644 tests/std/tests/native_latest_matrix.lst create mode 100644 tests/std/tests/native_matrix.lst create mode 100644 tests/std/tests/native_winsdk_matrix.lst create mode 100644 tests/std/tests/prefix.lst create mode 100644 tests/std/tests/rtti_matrix.lst create mode 100644 tests/std/tests/usual_17_matrix.lst create mode 100644 tests/std/tests/usual_17_winsdk_matrix.lst create mode 100644 tests/std/tests/usual_latest_matrix.lst create mode 100644 tests/std/tests/usual_latest_winsdk_matrix.lst create mode 100644 tests/std/tests/usual_matrix.lst create mode 100644 tests/std/tests/usual_winsdk_matrix.lst diff --git a/NOTICE.txt b/NOTICE.txt index 0dcad63048a..0e92d4512ee 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -127,3 +127,13 @@ In addition, certain files include the notices provided below. // Recipient is granted the right to make copies in any form for // internal distribution and to freely use the information supplied // in the creation of products supporting Unicode. + +---------------------- + +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// diff --git a/azure-devops/enforce-clang-format.cmd b/azure-devops/enforce-clang-format.cmd index 876dc51f680..f59ae28a7f8 100644 --- a/azure-devops/enforce-clang-format.cmd +++ b/azure-devops/enforce-clang-format.cmd @@ -3,7 +3,7 @@ "%1" "clang-format.exe -style=file -i" ^ stl/inc ^ stl/src ^ -tests/tr1 ^ +tests ^ tools @echo If your build fails here, you need to format the following files with: @clang-format.exe --version diff --git a/docs/cgmanifest.json b/docs/cgmanifest.json index 8efad40d7f3..e776c561d70 100644 --- a/docs/cgmanifest.json +++ b/docs/cgmanifest.json @@ -4,8 +4,8 @@ "component": { "type": "git", "git": { - "repositoryUrl": "https://github.com/ulfjack/ryu.git", - "commitHash": "59661c3f883dfd39cef6dc8eaf2fcbaae53597e8" + "repositoryUrl": "https://github.com/llvm/llvm-project.git", + "commitHash": "6f0768f64da398d5103d39e83bdc66a5ffd6f0f6" } } }, @@ -17,6 +17,15 @@ "commitHash": "07e85d10c051a0a53d522a28affb1fbc43fc24f0" } } + }, + { + "component": { + "type": "git", + "git": { + "repositoryUrl": "https://github.com/ulfjack/ryu.git", + "commitHash": "59661c3f883dfd39cef6dc8eaf2fcbaae53597e8" + } + } } ], "Version": 1 diff --git a/tests/std/include/constexpr_char_traits.hpp b/tests/std/include/constexpr_char_traits.hpp new file mode 100644 index 00000000000..26ec4fc86e5 --- /dev/null +++ b/tests/std/include/constexpr_char_traits.hpp @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +#include +#include + +struct constexpr_char_traits { + typedef char char_type; + typedef long int_type; + typedef long pos_type; + typedef long off_type; + typedef mbstate_t state_type; + + static constexpr int compare(const char* first1, const char* first2, size_t count) { + for (; 0 < count; --count, ++first1, ++first2) { + if (!eq(*first1, *first2)) { + return lt(*first1, *first2) ? -1 : +1; + } + } + + return 0; + } + + static constexpr size_t length(const char* first) { + size_t count = 0; + for (; !eq(*first, char()); ++first) { + ++count; + } + + return count; + } + + static constexpr char* copy(char* first1, const char* first2, size_t count) { + char* next = first1; + for (; 0 < count; --count, ++next, ++first2) { + assign(*next, *first2); + } + return first1; + } + + static constexpr char* _Copy_s(char* first1, size_t, const char* first2, size_t count) { + // let's just pretend :) + return copy(first1, first2, count); + } + + static constexpr const char* find(const char* first, size_t count, const char ch) { + for (; 0 < count; --count, ++first) { + if (eq(*first, ch)) { + return first; + } + } + + return nullptr; + } + + static constexpr char* move(char* first1, const char* first2, size_t count) { + char* next = first1; + if (first2 < next && next < first2 + count) { + for (next += count, first2 += count; 0 < count; --count) { + assign(*--next, *--first2); + } + } else { + for (; 0 < count; --count, ++next, ++first2) { + assign(*next, *first2); + } + } + return first1; + } + + static constexpr char* assign(char* first, size_t count, const char ch) { + char* next = first; + for (; 0 < count; --count, ++next) { + assign(*next, ch); + } + + return first; + } + + static constexpr void assign(char& left, const char right) noexcept { + left = right; + } + + static constexpr bool eq(const char left, const char right) noexcept { + return left == right; + } + + static constexpr bool lt(const char left, const char right) noexcept { + return left < right; + } + + static constexpr char to_char_type(const int_type meta) noexcept { + return static_cast(meta); + } + + static constexpr int_type to_int_type(const char ch) noexcept { + return ch; + } + + static constexpr bool eq_int_type(const int_type left, const int_type right) noexcept { + return left == right; + } + + static constexpr int_type not_eof(const int_type meta) noexcept { + return meta != eof() ? meta : !eof(); + } + + static constexpr int_type eof() noexcept { + return EOF; + } +}; diff --git a/tests/std/include/floating_point_test_cases.hpp b/tests/std/include/floating_point_test_cases.hpp new file mode 100644 index 00000000000..46b8172ead1 --- /dev/null +++ b/tests/std/include/floating_point_test_cases.hpp @@ -0,0 +1,275 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once + +#include +#include + +constexpr std::pair floating_point_test_cases_double[] = { + // Verify small exactly-representable integers: + {"1", 0x3FF0000000000000ULL}, + {"2", 0x4000000000000000ULL}, + {"3", 0x4008000000000000ULL}, + {"4", 0x4010000000000000ULL}, + {"5", 0x4014000000000000ULL}, + {"6", 0x4018000000000000ULL}, + {"7", 0x401C000000000000ULL}, + {"8", 0x4020000000000000ULL}, + + // Verify large exactly-representable integers: + {"9007199254740984", 0x433FFFFFFFFFFFF8ULL}, + {"9007199254740985", 0x433FFFFFFFFFFFF9ULL}, + {"9007199254740986", 0x433FFFFFFFFFFFFAULL}, + {"9007199254740987", 0x433FFFFFFFFFFFFBULL}, + {"9007199254740988", 0x433FFFFFFFFFFFFCULL}, + {"9007199254740989", 0x433FFFFFFFFFFFFDULL}, + {"9007199254740990", 0x433FFFFFFFFFFFFEULL}, + {"9007199254740991", 0x433FFFFFFFFFFFFFULL}, // 2^53 - 1 + + // Verify the smallest denormal values: + {"5.0e-324", 0x0000000000000001ULL}, + {"1.0e-323", 0x0000000000000002ULL}, + {"1.5e-323", 0x0000000000000003ULL}, + {"2.0e-323", 0x0000000000000004ULL}, + {"2.5e-323", 0x0000000000000005ULL}, + {"3.0e-323", 0x0000000000000006ULL}, + {"3.5e-323", 0x0000000000000007ULL}, + {"4.0e-323", 0x0000000000000008ULL}, + {"4.5e-323", 0x0000000000000009ULL}, + {"5.0e-323", 0x000000000000000AULL}, + {"5.5e-323", 0x000000000000000BULL}, + {"6.0e-323", 0x000000000000000CULL}, + {"6.5e-323", 0x000000000000000DULL}, + {"7.0e-323", 0x000000000000000EULL}, + {"7.5e-323", 0x000000000000000FULL}, + + // Verify the largest denormal values: + {"2.2250738585071935e-308", 0x000FFFFFFFFFFFF0ULL}, + {"2.2250738585071940e-308", 0x000FFFFFFFFFFFF1ULL}, + {"2.2250738585071945e-308", 0x000FFFFFFFFFFFF2ULL}, + {"2.2250738585071950e-308", 0x000FFFFFFFFFFFF3ULL}, + {"2.2250738585071955e-308", 0x000FFFFFFFFFFFF4ULL}, + {"2.2250738585071960e-308", 0x000FFFFFFFFFFFF5ULL}, + {"2.2250738585071964e-308", 0x000FFFFFFFFFFFF6ULL}, + {"2.2250738585071970e-308", 0x000FFFFFFFFFFFF7ULL}, + {"2.2250738585071974e-308", 0x000FFFFFFFFFFFF8ULL}, + {"2.2250738585071980e-308", 0x000FFFFFFFFFFFF9ULL}, + {"2.2250738585071984e-308", 0x000FFFFFFFFFFFFAULL}, + {"2.2250738585071990e-308", 0x000FFFFFFFFFFFFBULL}, + {"2.2250738585071994e-308", 0x000FFFFFFFFFFFFCULL}, + {"2.2250738585072000e-308", 0x000FFFFFFFFFFFFDULL}, + {"2.2250738585072004e-308", 0x000FFFFFFFFFFFFEULL}, + {"2.2250738585072010e-308", 0x000FFFFFFFFFFFFFULL}, + + // DevDiv#576315 "I/O library incorrect rounds floating point numbers on input" + // DevDiv#616647 "Visual C++ 11: iostream bug: incorrect input streaming of the smallest normal double and some + // denormals" + // DevDiv#730414 "iostreams is still misparsing floating-point" + // DevDiv#938627 "parsing float values using std::istream gives results inconsistent with sscanf() and with C++ + // compiler" + // DevDiv#961116 "floating point string conversion accuracy" + {"2.2250738585072014e-308", 0x0010000000000000ULL}, // DBL_MIN + {"1.7976931348623158e+308", 0x7FEFFFFFFFFFFFFFULL}, // DBL_MAX + {"4.26144921954407e-309", 0x00031076B2F00000ULL}, + {"179.9999999999999855", 0x40667FFFFFFFFFFFULL}, + {"4.1", 0x4010666666666666ULL}, + {"0.2288884", 0x3FCD4C37103785A8ULL}, + {"0.168", 0x3FC5810624DD2F1BULL}, + {"1.68", 0x3FFAE147AE147AE1ULL}, + {"16.80000001", 0x4030CCCCCCF7BFEBULL}, + + // Test cases from Rick Regan's article, "Incorrectly Rounded Conversions in Visual C++": + // https://www.exploringbinary.com/incorrectly-rounded-conversions-in-visual-c-plus-plus/ + + // Example 1: + {"9214843084008499", 0x43405E6CEC57761AULL}, + + // Example 2 (2^-1 + 2^-53 + 2^-54): + {"0.500000000000000166533453693773481063544750213623046875", 0x3FE0000000000002ULL}, + + // Example 3: + {"30078505129381147446200", 0x44997A3C7271B021ULL}, + + // Example 4: + {"1777820000000000000001", 0x4458180D5BAD2E3EULL}, + + // Example 5 (2^-1 + 2^-53 + 2^-54 + 2^-66): + {"0.500000000000000166547006220929549868969843373633921146392822265625", 0x3FE0000000000002ULL}, + + // Example 6 (2^-1 + 2^-53 + 2^-54 + 2^-65): + {"0.50000000000000016656055874808561867439493653364479541778564453125", 0x3FE0000000000002ULL}, + + // Example 7: + {"0.3932922657273", 0x3FD92BB352C4623AULL}, + + // The following test cases are taken from other articles on Rick Regan's + // Exploring Binary blog. These are conversions that other implementations + // were found to perform incorrectly. + + // https://www.exploringbinary.com/incorrectly-rounded-subnormal-conversions-in-java/ + // Example 1 (2^-1047 + 2^-1075, half-ulp above a power of two): + {"6.6312368714697582767853966302759672433990999473553031442499717587" + "362866301392654396180682007880487441059604205526018528897150063763" + "256665955396033303618005191075917832333584923372080578494993608994" + "251286407188566165030934449228547591599881603044399098682919739314" + "266256986631577498362522745234853124423586512070512924530832781161" + "439325697279187097860044978723221938561502254152119972830784963194" + "121246401117772161481107528151017752957198119743384519360959074196" + "224175384736794951486324803914359317679811223967034438033355297560" + "033532098300718322306892013830155987921841729099279241763393155074" + "022348361207309147831684007154624400538175927027662135590421159867" + "638194826541287705957668068727833491469671712939495988506756821156" + "96218943412532098591327667236328125E-316", + 0x0000000008000000ULL}, + + // Example 2 (2^-1058 - 2^-1075, half-ulp below a power of two): + {"3.2378839133029012895883524125015321748630376694231080599012970495" + "523019706706765657868357425877995578606157765598382834355143910841" + "531692526891905643964595773946180389283653051434639551003566966656" + "292020173313440317300443693602052583458034314716600326995807313009" + "548483639755486900107515300188817581841745696521731104736960227499" + "346384253806233697747365600089974040609674980283891918789639685754" + "392222064169814626901133425240027243859416510512935526014211553334" + "302252372915238433223313261384314778235911424088000307751706259156" + "707286570031519536642607698224949379518458015308952384398197084033" + "899378732414634842056080000272705311068273879077914449185347715987" + "501628125488627684932015189916680282517302999531439241685457086639" + "13273994694463908672332763671875E-319", + 0x0000000000010000ULL}, + + // Example 3 (2^-1027 + 2^-1066 + 2^-1075, half-ulp above a non-power of two): + {"6.9533558078476771059728052155218916902221198171459507544162056079" + "800301315496366888061157263994418800653863998640286912755395394146" + "528315847956685600829998895513577849614468960421131982842131079351" + "102171626549398024160346762138294097205837595404767869364138165416" + "212878432484332023692099166122496760055730227032447997146221165421" + "888377703760223711720795591258533828013962195524188394697705149041" + "926576270603193728475623010741404426602378441141744972109554498963" + "891803958271916028866544881824524095839813894427833770015054620157" + "450178487545746683421617594966617660200287528887833870748507731929" + "971029979366198762266880963149896457660004790090837317365857503352" + "620998601508967187744019647968271662832256419920407478943826987518" + "09812609536720628966577351093292236328125E-310", + 0x0000800000000100ULL}, + + // Example 4 (2^-1058 + 2^-1063 - 2^-1075, half-ulp below a non-power of two): + {"3.3390685575711885818357137012809439119234019169985217716556569973" + "284403145596153181688491490746626090999981130094655664268081703784" + "340657229916596426194677060348844249897410807907667784563321682004" + "646515939958173717821250106683466529959122339932545844611258684816" + "333436749050742710644097630907080178565840197768788124253120088123" + "262603630354748115322368533599053346255754042160606228586332807443" + "018924703005556787346899784768703698535494132771566221702458461669" + "916553215355296238706468887866375289955928004361779017462862722733" + "744717014529914330472578638646014242520247915673681950560773208853" + "293843223323915646452641434007986196650406080775491621739636492640" + "497383622906068758834568265867109610417379088720358034812416003767" + "05491726170293986797332763671875E-319", + 0x0000000000010800ULL}, + + // A number between 2^-1074 and 2^-1075, just slightly larger than 2^-1075. + // It has bit 1075 set (the denormal rounding bit), followed by 2506 zeroes, + // followed by one bits. It should round up to 2^-1074. + {"2.470328229206232720882843964341106861825299013071623822127928412503" + "37753635104375932649918180817996189898282347722858865463328355177969" + "89819938739800539093906315035659515570226392290858392449105184435931" + "80284993653615250031937045767824921936562366986365848075700158576926" + "99037063119282795585513329278343384093519780155312465972635795746227" + "66465272827220056374006485499977096599470454020828166226237857393450" + "73633900796776193057750674017632467360096895134053553745851666113422" + "37666786041621596804619144672918403005300575308490487653917113865916" + "46239524912623653881879636239373280423891018672348497668235089863388" + "58792562830275599565752445550725518931369083625477918694866799496832" + "40497058210285131854513962138377228261454376934125320985913276672363" + "28125001e-324", + 0x0000000000000001ULL}, + + // This value has a non-terminating binary fraction. It has a 0 at bit 54 followed by 120 ones. + {"1.8254370818746402660437411213933955878019332885742187", 0x3FFD34FD8378EA83ULL}, + + // https://www.exploringbinary.com/incorrect-decimal-to-floating-point-conversion-in-sqlite/ + {"1e-23", 0x3B282DB34012B251ULL}, + {"8.533e+68", 0x4E3FA69165A8EEA2ULL}, + {"4.1006e-184", 0x19DBE0D1C7EA60C9ULL}, + {"9.998e+307", 0x7FE1CC0A350CA87BULL}, + {"9.9538452227e-280", 0x0602117AE45CDE43ULL}, + {"6.47660115e-260", 0x0A1FDD9E333BADADULL}, + {"7.4e+47", 0x49E033D7ECA0ADEFULL}, + {"5.92e+48", 0x4A1033D7ECA0ADEFULL}, + {"7.35e+66", 0x4DD172B70EABABA9ULL}, + {"8.32116e+55", 0x4B8B2628393E02CDULL}, +}; + +constexpr std::pair floating_point_test_cases_float[] = { + // Verify small exactly-representable integers: + {"1", 0x3F800000U}, + {"2", 0x40000000U}, + {"3", 0x40400000U}, + {"4", 0x40800000U}, + {"5", 0x40A00000U}, + {"6", 0x40C00000U}, + {"7", 0x40E00000U}, + {"8", 0x41000000U}, + + // Verify large exactly-representable integers: + {"16777208", 0x4B7FFFF8U}, + {"16777209", 0x4B7FFFF9U}, + {"16777210", 0x4B7FFFFAU}, + {"16777211", 0x4B7FFFFBU}, + {"16777212", 0x4B7FFFFCU}, + {"16777213", 0x4B7FFFFDU}, + {"16777214", 0x4B7FFFFEU}, + {"16777215", 0x4B7FFFFFU}, // 2^24 - 1 + + // Verify the smallest denormal values: + {"1.4012984643248170e-45", 0x00000001U}, + {"2.8025969286496340e-45", 0x00000002U}, + {"4.2038953929744510e-45", 0x00000003U}, + {"5.6051938572992680e-45", 0x00000004U}, + {"7.0064923216240850e-45", 0x00000005U}, + {"8.4077907859489020e-45", 0x00000006U}, + {"9.8090892502737200e-45", 0x00000007U}, + {"1.1210387714598537e-44", 0x00000008U}, + {"1.2611686178923354e-44", 0x00000009U}, + {"1.4012984643248170e-44", 0x0000000AU}, + {"1.5414283107572988e-44", 0x0000000BU}, + {"1.6815581571897805e-44", 0x0000000CU}, + {"1.8216880036222622e-44", 0x0000000DU}, + {"1.9618178500547440e-44", 0x0000000EU}, + {"2.1019476964872256e-44", 0x0000000FU}, + + // Verify the largest denormal values: + {"1.1754921087447446e-38", 0x007FFFF0U}, + {"1.1754922488745910e-38", 0x007FFFF1U}, + {"1.1754923890044375e-38", 0x007FFFF2U}, + {"1.1754925291342839e-38", 0x007FFFF3U}, + {"1.1754926692641303e-38", 0x007FFFF4U}, + {"1.1754928093939768e-38", 0x007FFFF5U}, + {"1.1754929495238232e-38", 0x007FFFF6U}, + {"1.1754930896536696e-38", 0x007FFFF7U}, + {"1.1754932297835160e-38", 0x007FFFF8U}, + {"1.1754933699133625e-38", 0x007FFFF9U}, + {"1.1754935100432089e-38", 0x007FFFFAU}, + {"1.1754936501730553e-38", 0x007FFFFBU}, + {"1.1754937903029018e-38", 0x007FFFFCU}, + {"1.1754939304327482e-38", 0x007FFFFDU}, + {"1.1754940705625946e-38", 0x007FFFFEU}, + {"1.1754942106924411e-38", 0x007FFFFFU}, + + // DevDiv#576315 "I/O library incorrect rounds floating point numbers on input" + // DevDiv#616647 "Visual C++ 11: iostream bug: incorrect input streaming of the smallest normal double and some + // denormals" + // DevDiv#730414 "iostreams is still misparsing floating-point" + // DevDiv#938627 "parsing float values using std::istream gives results inconsistent with sscanf() and with C++ + // compiler" + // DevDiv#961116 "floating point string conversion accuracy" + {"1.175494351e-38", 0x00800000U}, // FLT_MIN + {"3.402823466e+38", 0x7F7FFFFFU}, // FLT_MAX + {"179.9999999999999855", 0x43340000U}, + {"4.1", 0x40833333U}, + {"0.2288884", 0x3E6A61B9U}, + {"0.168", 0x3E2C0831U}, + {"1.68", 0x3FD70A3DU}, + {"16.80000001", 0x41866666U}, +}; diff --git a/tests/std/include/input_iterator.hpp b/tests/std/include/input_iterator.hpp new file mode 100644 index 00000000000..74f645e4cd9 --- /dev/null +++ b/tests/std/include/input_iterator.hpp @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once + +#include +#include +#include +#include +#include + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +// No STL containers support only input_iterator_tag (just stuff like istream_iterator). +// input_iterator_container is a range that only supports input iterators +// with added unchecked/rechecked functionality to ensure we traverse those code paths +namespace std_testing { + + template + struct const_unchecked_input_iterator { + using difference_type = std::ptrdiff_t; + using value_type = T; + using pointer = const T*; + using reference = const T&; + using iterator_category = std::input_iterator_tag; + using my_iter = const_unchecked_input_iterator; + + explicit const_unchecked_input_iterator(const T* val) : m_val(const_cast(val)) {} + const_unchecked_input_iterator(const const_unchecked_input_iterator&) = default; + const_unchecked_input_iterator(const_unchecked_input_iterator&&) = default; + const_unchecked_input_iterator& operator=(const const_unchecked_input_iterator&) = default; + const_unchecked_input_iterator& operator=(const_unchecked_input_iterator&&) = default; + + reference operator*() const { + return *m_val; + } + + pointer operator->() const { + return m_val; + } + + my_iter& operator++() { + ++m_val; + return *this; + } + + void operator++(int) = delete; // avoid postincrement + + bool operator==(const my_iter& right) const { + return m_val == right.m_val; + } + + bool operator!=(const my_iter& right) const { + return !(*this == right); + } + + T* m_val; + + protected: + explicit const_unchecked_input_iterator(T* val) : m_val(val) {} + }; + + template + struct unchecked_input_iterator : const_unchecked_input_iterator { + using difference_type = std::ptrdiff_t; + using value_type = T; + using pointer = T*; + using reference = T&; + using iterator_category = std::input_iterator_tag; + using my_iter = unchecked_input_iterator; + + explicit unchecked_input_iterator(T* val) : const_unchecked_input_iterator(val) {} + unchecked_input_iterator(const unchecked_input_iterator&) = default; + unchecked_input_iterator(unchecked_input_iterator&&) = default; + unchecked_input_iterator& operator=(const unchecked_input_iterator&) = default; + unchecked_input_iterator& operator=(unchecked_input_iterator&&) = default; + + reference operator*() const { + return *this->m_val; + } + + pointer operator->() const { + return this->m_val; + } + + my_iter& operator++() { + ++this->m_val; + return *this; + } + + void operator++(int) = delete; // avoid postincrement + }; + + template + struct const_checked_input_iterator : const_unchecked_input_iterator { + using difference_type = std::ptrdiff_t; + using value_type = T; + using pointer = const T*; + using reference = const T&; + using iterator_category = std::input_iterator_tag; + using my_iter = const_checked_input_iterator; + + explicit const_checked_input_iterator(const T* val) : const_unchecked_input_iterator(val) {} + const_checked_input_iterator(const const_checked_input_iterator&) = default; + const_checked_input_iterator(const_checked_input_iterator&&) = default; + const_checked_input_iterator& operator=(const const_checked_input_iterator&) = default; + const_checked_input_iterator& operator=(const_checked_input_iterator&&) = default; + + void _Seek_to(const_unchecked_input_iterator right) { + this->m_val = right.m_val; + } + + const_unchecked_input_iterator _Unwrapped() const { + return const_unchecked_input_iterator(this->m_val); + } + + static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0; + + my_iter& operator++() { + ++this->m_val; + return *this; + } + + void operator++(int) = delete; // avoid postincrement + }; + + template + struct checked_input_iterator : unchecked_input_iterator { + using difference_type = std::ptrdiff_t; + using value_type = T; + using pointer = T*; + using reference = T&; + using iterator_category = std::input_iterator_tag; + using my_iter = checked_input_iterator; + + explicit checked_input_iterator(T* val) : unchecked_input_iterator(val) {} + checked_input_iterator(const checked_input_iterator&) = default; + checked_input_iterator(checked_input_iterator&&) = default; + checked_input_iterator& operator=(const checked_input_iterator&) = default; + checked_input_iterator& operator=(checked_input_iterator&&) = default; + + void _Seek_to(unchecked_input_iterator right) { + this->m_val = right.m_val; + } + + unchecked_input_iterator _Unwrapped() const { + return unchecked_input_iterator(this->m_val); + } + + static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0; + + my_iter& operator++() { + ++this->m_val; + return *this; + } + + void operator++(int) = delete; // avoid postincrement + }; + + template + struct input_iterator_container { + using impl_value = std::conditional_t, char, T>; // avoid vector nonsense + STATIC_ASSERT(sizeof(impl_value) == sizeof(T)); + STATIC_ASSERT(alignof(impl_value) == alignof(T)); + + using iterator = checked_input_iterator; + using const_iterator = const_checked_input_iterator; + + input_iterator_container() = default; + + template + input_iterator_container(InIt first, InIt last) : m_val(first, last) {} + + input_iterator_container(std::initializer_list init_list) + : input_iterator_container(init_list.begin(), init_list.end()) {} + + input_iterator_container(const input_iterator_container&) = default; + input_iterator_container(input_iterator_container&&) = default; + input_iterator_container& operator=(const input_iterator_container&) = default; + input_iterator_container& operator=(input_iterator_container&&) = default; + + const_iterator begin() const { + return const_iterator{reinterpret_cast(m_val.data())}; + } + const_iterator end() const { + return const_iterator{reinterpret_cast(m_val.data()) + m_val.size()}; + } + iterator begin() { + return iterator{reinterpret_cast(m_val.data())}; + } + iterator end() { + return iterator{reinterpret_cast(m_val.data()) + m_val.size()}; + } + + const_iterator cbegin() const { + return begin(); + } + const_iterator cend() const { + return end(); + } + + std::vector m_val; + }; +} + +#undef STATIC_ASSERT diff --git a/tests/std/include/instantiate_algorithms.hpp b/tests/std/include/instantiate_algorithms.hpp new file mode 100644 index 00000000000..70161186516 --- /dev/null +++ b/tests/std/include/instantiate_algorithms.hpp @@ -0,0 +1,837 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +// This tests all STL algorithms, including and . +// Notably, all permutations of all iterator strengths are tested. + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if _HAS_CXX17 && !defined(_M_CEE) +#define HAS_PARALLEL_ALGORITHMS 1 +#else +#define HAS_PARALLEL_ALGORITHMS 0 +#endif // _HAS_CXX17 && !defined(_M_CEE) + +#if HAS_PARALLEL_ALGORITHMS +#include +#endif // HAS_PARALLEL_ALGORITHMS + +// Compiling all algorithms takes too long for one test case. +// Therefore, when using this header, be sure to define INSTANTIATE_ALGORITHMS_SPLIT_MODE +// to indicate if this should compile part 1 or part 2. +#if !defined(INSTANTIATE_ALGORITHMS_SPLIT_MODE) || INSTANTIATE_ALGORITHMS_SPLIT_MODE < 1 \ + || INSTANTIATE_ALGORITHMS_SPLIT_MODE > 2 +#error INSTANTIATE_ALGORITHMS_SPLIT_MODE must be defined to 1 or 2. +#endif + +namespace std_testing { + + template + struct identity_impl { + typedef Ty type; + }; + + template + using identity_t = typename identity_impl::type; + + namespace dummy_functors { + // Various functors required by various algorithms. + // Note that the standard actually requires these to be copyable. As a "nonstandard extension" we want + // to ensure we don't copy them, because copying some functors (e.g. std::function) is comparatively + // expensive, and even for relatively cheap to copy function objects we care (somewhat) about debug + // mode perf. + + struct MoveOnly { + MoveOnly() = default; + MoveOnly(const MoveOnly&) = delete; + MoveOnly(MoveOnly&&) = default; + MoveOnly& operator=(const MoveOnly&) = delete; + MoveOnly& operator=(MoveOnly&&) = delete; + }; + + template + struct Predicate : MoveOnly { + bool operator()(const T&) const { + return true; + } + }; + + template + struct BiPredicate : MoveOnly { + bool operator()(const T&, const T&) const { + return true; + } + }; + + template + struct UnaryOperation : MoveOnly { + T operator()(const T&) const { + return {}; + } + }; + + template + struct BinaryOperation : MoveOnly { + T operator()(const T&, const T&) const { + return {}; + } + }; + + template + struct Generator : MoveOnly { + T operator()() const { + return {}; + } + }; + + template + struct Function : MoveOnly { + void operator()(const T&) {} + }; + + struct Rng : MoveOnly { + template + Integral operator()(Integral) { + return 0; + } + }; + + struct Urng : MoveOnly { + typedef unsigned int result_type; + unsigned int operator()() { + return 4; // chosen by fair dice roll; guaranteed to be random + } + static constexpr unsigned int min() { + return 0; + } + static constexpr unsigned int max() { + return 100; + } + }; + + // Check for op,() + template + void operator,(const T&, const U&) = delete; + } + + + template + struct algorithms_tester { + + // The convention here is that "UPPERCASE" variables are fixed types, while + // "lowercase" variables are varying types. + // For example, "FWDIT" is always a forward-only iterator, while "fwd1" + // is a forward-or-better iterator. + + ValueType VAL; + ValueType VALARR[10]; + + ValueType (&ARRIT)[10] = VALARR; + typedef decltype(ARRIT) ArrIt; + + typedef BIPRED COMP; + + InIt INIT; + FwdIt FWDIT; + BidIt BIDIT; + RanIt RANIT; + OutIt OUTIT; + + template + typename std::iterator_traits::difference_type Get_size(Iter) { + return {}; + } + +#if INSTANTIATE_ALGORITHMS_SPLIT_MODE == 1 + std::list LST; + std::forward_list FLST; +#endif // SPLIT_MODE + + algorithms_tester(InIt a, FwdIt b, BidIt c, RanIt d, OutIt e) + : INIT(a), FWDIT(b), BIDIT(c), RANIT(d), OUTIT(e) {} + + // Now, test everything! + template + void test_in1_in2_out(identity_t in1, identity_t in2, identity_t out) { +#if INSTANTIATE_ALGORITHMS_SPLIT_MODE == 1 + std::transform(in1, in1, in2, out, BINARYOP{}); + std::merge(in1, in1, in2, in2, out); + std::merge(in1, in1, in2, in2, out, COMP{}); + std::set_union(in1, in1, in2, in2, out); + std::set_union(in1, in1, in2, in2, out, COMP{}); +#else // ^^^ SPLIT_MODE 1 ^^^ // vvv SPLIT_MODE 2 vvv // + std::set_intersection(in1, in1, in2, in2, out); + std::set_intersection(in1, in1, in2, in2, out, COMP{}); + std::set_difference(in1, in1, in2, in2, out); + std::set_difference(in1, in1, in2, in2, out, COMP{}); + std::set_symmetric_difference(in1, in1, in2, in2, out); + std::set_symmetric_difference(in1, in1, in2, in2, out, COMP{}); +#endif // SPLIT_MODE + } + + template + void test_in1_in2(identity_t in1, identity_t in2) { + test_in1_in2_out(in1, in2, OUTIT); + test_in1_in2_out(in1, in2, INIT); + test_in1_in2_out(in1, in2, FWDIT); + test_in1_in2_out(in1, in2, BIDIT); + test_in1_in2_out(in1, in2, RANIT); + test_in1_in2_out(in1, in2, ARRIT); + +#if INSTANTIATE_ALGORITHMS_SPLIT_MODE == 2 + (void) std::mismatch(in1, in1, in2); + (void) std::mismatch(in1, in1, in2, BIPRED{}); + (void) std::mismatch(in1, in1, in2, in2); + (void) std::mismatch(in1, in1, in2, in2, BIPRED{}); + (void) std::equal(in1, in1, in2); + (void) std::equal(in1, in1, in2, BIPRED{}); + (void) std::equal(in1, in1, in2, in2); + (void) std::equal(in1, in1, in2, in2, BIPRED{}); + (void) std::includes(in1, in1, in2, in2); + (void) std::includes(in1, in1, in2, in2, COMP{}); + (void) std::lexicographical_compare(in1, in1, in2, in2); + (void) std::lexicographical_compare(in1, in1, in2, in2, COMP{}); + + (void) std::inner_product(in1, in1, in2, VAL); + (void) std::inner_product(in1, in1, in2, VAL, BINARYOP{}, BINARYOP{}); +#if _HAS_CXX17 + (void) std::transform_reduce(in1, in1, in2, VAL); + (void) std::transform_reduce(in1, in1, in2, VAL, BINARYOP{}, BINARYOP{}); +#endif // _HAS_CXX17 +#endif // SPLIT_MODE + } + + template + void test_in1_fwd1(identity_t in1, identity_t fwd1) { + // SPLIT_MODE 1 + (void) std::find_first_of(in1, in1, fwd1, fwd1); + (void) std::find_first_of(in1, in1, fwd1, fwd1, BIPRED{}); + + std::uninitialized_copy(in1, in1, fwd1); + std::uninitialized_copy_n(in1, Get_size(in1), fwd1); +#if _HAS_CXX17 + std::uninitialized_move(in1, in1, fwd1); + std::uninitialized_move_n(in1, Get_size(in1), fwd1); +#endif // _HAS_CXX17 + } + + template + void test_in1_out_out2(identity_t in1, identity_t out, identity_t out2) { + // SPLIT_MODE 1 + std::partition_copy(in1, in1, out, out2, PRED{}); + } + + template + void test_in1_out(identity_t in1, identity_t out) { + // SPLIT_MODE 1 + test_in1_out_out2(in1, out, OUTIT); + test_in1_out_out2(in1, out, INIT); + test_in1_out_out2(in1, out, FWDIT); + test_in1_out_out2(in1, out, BIDIT); + test_in1_out_out2(in1, out, RANIT); + test_in1_out_out2(in1, out, ARRIT); + + std::copy(in1, in1, out); + std::copy_n(in1, Get_size(in1), out); + std::copy_if(in1, in1, out, PRED{}); + std::move(in1, in1, out); + std::transform(in1, in1, out, UNARYOP{}); + std::replace_copy(in1, in1, out, VAL, VAL); + std::replace_copy_if(in1, in1, out, PRED{}, VAL); + std::remove_copy(in1, in1, out, VAL); + std::remove_copy_if(in1, in1, out, PRED{}); + std::unique_copy(in1, in1, out); + std::unique_copy(in1, in1, out, BIPRED{}); + + std::partial_sum(in1, in1, out); + std::partial_sum(in1, in1, out, BINARYOP{}); +#if _HAS_CXX17 + std::exclusive_scan(in1, in1, out, VAL); + std::exclusive_scan(in1, in1, out, VAL, BINARYOP{}); + std::inclusive_scan(in1, in1, out); + std::inclusive_scan(in1, in1, out, BINARYOP{}); + std::inclusive_scan(in1, in1, out, BINARYOP{}, VAL); + std::transform_exclusive_scan(in1, in1, out, VAL, BINARYOP{}, UNARYOP{}); + std::transform_inclusive_scan(in1, in1, out, BINARYOP{}, UNARYOP{}); + std::transform_inclusive_scan(in1, in1, out, BINARYOP{}, UNARYOP{}, VAL); +#endif // _HAS_CXX17 + std::adjacent_difference(in1, in1, out); + std::adjacent_difference(in1, in1, out, BINARYOP{}); + } + + template + void test_in1(identity_t in1) { + test_in1_in2(in1, INIT); + test_in1_in2(in1, FWDIT); + test_in1_in2(in1, BIDIT); + test_in1_in2(in1, RANIT); + test_in1_in2(in1, ARRIT); + +#if INSTANTIATE_ALGORITHMS_SPLIT_MODE == 1 + test_in1_fwd1(in1, FWDIT); + test_in1_fwd1(in1, BIDIT); + test_in1_fwd1(in1, RANIT); + test_in1_fwd1(in1, ARRIT); + + test_in1_out(in1, OUTIT); + test_in1_out(in1, INIT); + test_in1_out(in1, FWDIT); + test_in1_out(in1, BIDIT); + test_in1_out(in1, RANIT); + test_in1_out(in1, ARRIT); + + LST.assign(in1, in1); + LST.insert(LST.end(), in1, in1); + + FLST.assign(in1, in1); + FLST.insert_after(FLST.begin(), in1, in1); + +#else // ^^^ SPLIT_MODE 1 ^^^ // vvv SPLIT_MODE 2 vvv // + (void) std::all_of(in1, in1, PRED{}); + (void) std::any_of(in1, in1, PRED{}); + (void) std::none_of(in1, in1, PRED{}); + std::for_each(in1, in1, FUNCTION{}); +#if _HAS_CXX17 + std::for_each_n(in1, Get_size(in1), FUNCTION{}); +#endif // _HAS_CXX17 + (void) std::find(in1, in1, VAL); + (void) std::find_if(in1, in1, PRED{}); + (void) std::find_if_not(in1, in1, PRED{}); + (void) std::count(in1, in1, VAL); + (void) std::count_if(in1, in1, PRED{}); + (void) std::is_partitioned(in1, in1, PRED{}); + std::partial_sort_copy(in1, in1, RANIT, RANIT); + std::partial_sort_copy(in1, in1, RANIT, RANIT, COMP{}); +#if _HAS_CXX17 + std::sample(in1, in1, RANIT, Get_size(in1), URNG{}); + std::sample(in1, in1, ARRIT, Get_size(in1), URNG{}); +#endif // _HAS_CXX17 + + (void) std::accumulate(in1, in1, VAL); + (void) std::accumulate(in1, in1, VAL, BINARYOP{}); +#if _HAS_CXX17 + (void) std::reduce(in1, in1); + (void) std::reduce(in1, in1, VAL); + (void) std::reduce(in1, in1, VAL, BINARYOP{}); + (void) std::transform_reduce(in1, in1, VAL, BINARYOP{}, UNARYOP{}); +#endif // _HAS_CXX17 + + +#endif // SPLIT_MODE + } + +#if HAS_PARALLEL_ALGORITHMS + template + void test_exec_fwd1_fwd2_fwd3( + ExecutionPolicy&& exec, identity_t fwd1, identity_t fwd2, identity_t fwd3) { + std::transform(std::forward(exec), fwd1, fwd1, fwd2, fwd3, BINARYOP{}); + + std::partition_copy(std::forward(exec), fwd1, fwd1, fwd2, fwd3, PRED{}); + + std::merge(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3); + std::merge(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3, COMP{}); + + std::set_union(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3); + std::set_union(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3, COMP{}); + std::set_intersection(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3); + std::set_intersection(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3, COMP{}); + std::set_difference(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3); + std::set_difference(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3, COMP{}); + std::set_symmetric_difference(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3); + std::set_symmetric_difference(std::forward(exec), fwd1, fwd1, fwd2, fwd2, fwd3, COMP{}); + } + + template + void test_exec_fwd1_fwd2(ExecutionPolicy&& exec, identity_t fwd1, identity_t fwd2) { + test_exec_fwd1_fwd2_fwd3(std::forward(exec), fwd1, fwd2, FWDIT); + test_exec_fwd1_fwd2_fwd3(std::forward(exec), fwd1, fwd2, BIDIT); + test_exec_fwd1_fwd2_fwd3(std::forward(exec), fwd1, fwd2, RANIT); + test_exec_fwd1_fwd2_fwd3(std::forward(exec), fwd1, fwd2, ARRIT); + + (void) std::find_end(std::forward(exec), fwd1, fwd1, fwd2, fwd2); + (void) std::find_end(std::forward(exec), fwd1, fwd1, fwd2, fwd2, BIPRED{}); + (void) std::find_first_of(std::forward(exec), fwd1, fwd1, fwd2, fwd2); + (void) std::find_first_of(std::forward(exec), fwd1, fwd1, fwd2, fwd2, BIPRED{}); + (void) std::mismatch(std::forward(exec), fwd1, fwd1, fwd2); + (void) std::mismatch(std::forward(exec), fwd1, fwd1, fwd2, BIPRED{}); + (void) std::mismatch(std::forward(exec), fwd1, fwd1, fwd2, fwd2); + (void) std::mismatch(std::forward(exec), fwd1, fwd1, fwd2, fwd2, BIPRED{}); + (void) std::equal(std::forward(exec), fwd1, fwd1, fwd2); + (void) std::equal(std::forward(exec), fwd1, fwd1, fwd2, BIPRED{}); + (void) std::equal(std::forward(exec), fwd1, fwd1, fwd2, fwd2); + (void) std::equal(std::forward(exec), fwd1, fwd1, fwd2, fwd2, BIPRED{}); + (void) std::search(std::forward(exec), fwd1, fwd1, fwd2, fwd2); + (void) std::search(std::forward(exec), fwd1, fwd1, fwd2, fwd2, BIPRED{}); + + std::copy(std::forward(exec), fwd1, fwd1, fwd2); + std::copy_if(std::forward(exec), fwd1, fwd1, fwd2, PRED{}); + std::copy_n(std::forward(exec), fwd1, Get_size(fwd1), fwd2); + std::move(std::forward(exec), fwd1, fwd1, fwd2); + std::swap_ranges(std::forward(exec), fwd1, fwd1, fwd2); + std::transform(std::forward(exec), fwd1, fwd1, fwd2, UNARYOP{}); + std::rotate_copy(std::forward(exec), fwd1, fwd1, fwd1, fwd2); + std::replace_copy(std::forward(exec), fwd1, fwd1, fwd2, VAL, VAL); + std::replace_copy_if(std::forward(exec), fwd1, fwd1, fwd2, PRED{}, VAL); + std::remove_copy(std::forward(exec), fwd1, fwd1, fwd2, VAL); + std::remove_copy_if(std::forward(exec), fwd1, fwd1, fwd2, PRED{}); + std::unique_copy(std::forward(exec), fwd1, fwd1, fwd2); + std::unique_copy(std::forward(exec), fwd1, fwd1, fwd2, BIPRED{}); + + (void) std::includes(std::forward(exec), fwd1, fwd1, fwd2, fwd2); + (void) std::includes(std::forward(exec), fwd1, fwd1, fwd2, fwd2, COMP{}); + + (void) std::lexicographical_compare(std::forward(exec), fwd1, fwd1, fwd2, fwd2); + (void) std::lexicographical_compare(std::forward(exec), fwd1, fwd1, fwd2, fwd2, COMP{}); + + (void) std::transform_reduce(std::forward(exec), fwd1, fwd1, fwd2, VAL); + (void) std::transform_reduce( + std::forward(exec), fwd1, fwd1, fwd2, VAL, BINARYOP{}, BINARYOP{}); + std::exclusive_scan(std::forward(exec), fwd1, fwd1, fwd2, VAL); + std::exclusive_scan(std::forward(exec), fwd1, fwd1, fwd2, VAL, BINARYOP{}); + std::inclusive_scan(std::forward(exec), fwd1, fwd1, fwd2); + std::inclusive_scan(std::forward(exec), fwd1, fwd1, fwd2, BINARYOP{}); + std::inclusive_scan(std::forward(exec), fwd1, fwd1, fwd2, BINARYOP{}, VAL); + std::transform_exclusive_scan( + std::forward(exec), fwd1, fwd1, fwd2, VAL, BINARYOP{}, UNARYOP{}); + std::transform_inclusive_scan(std::forward(exec), fwd1, fwd1, fwd2, BINARYOP{}, UNARYOP{}); + std::transform_inclusive_scan( + std::forward(exec), fwd1, fwd1, fwd2, BINARYOP{}, UNARYOP{}, VAL); + std::adjacent_difference(std::forward(exec), fwd1, fwd1, fwd2); + std::adjacent_difference(std::forward(exec), fwd1, fwd1, fwd2, BINARYOP{}); + } +#endif // HAS_PARALLEL_ALGORITHMS + + template + void test_fwd1_fwd2(identity_t fwd1, identity_t fwd2) { + // SPLIT_MODE 1 +#if HAS_PARALLEL_ALGORITHMS + test_exec_fwd1_fwd2(std::execution::seq, fwd1, fwd2); + test_exec_fwd1_fwd2(std::execution::par, fwd1, fwd2); + test_exec_fwd1_fwd2(std::execution::par_unseq, fwd1, fwd2); +#endif // HAS_PARALLEL_ALGORITHMS + + (void) std::find_end(fwd1, fwd1, fwd2, fwd2); + (void) std::find_end(fwd1, fwd1, fwd2, fwd2, BIPRED{}); + (void) std::is_permutation(fwd1, fwd1, fwd2); + (void) std::is_permutation(fwd1, fwd1, fwd2, BIPRED{}); + (void) std::is_permutation(fwd1, fwd1, fwd2, fwd2); + (void) std::is_permutation(fwd1, fwd1, fwd2, fwd2, BIPRED{}); + (void) std::search(fwd1, fwd1, fwd2, fwd2); + (void) std::search(fwd1, fwd1, fwd2, fwd2, BIPRED{}); + std::swap_ranges(fwd1, fwd1, fwd2); + std::iter_swap(fwd1, fwd2); + } + + template + void test_fwd1_out(identity_t fwd1, identity_t out) { + // SPLIT_MODE 2 + std::rotate_copy(fwd1, fwd1, fwd1, out); +#if _HAS_CXX17 + std::sample(fwd1, fwd1, out, Get_size(fwd1), URNG{}); +#endif // _HAS_CXX17 + } + +#if HAS_PARALLEL_ALGORITHMS + template + void test_exec_fwd1(ExecutionPolicy&& exec, identity_t fwd1) { + (void) std::all_of(std::forward(exec), fwd1, fwd1, PRED{}); + (void) std::any_of(std::forward(exec), fwd1, fwd1, PRED{}); + (void) std::none_of(std::forward(exec), fwd1, fwd1, PRED{}); + std::for_each(std::forward(exec), fwd1, fwd1, FUNCTION{}); + std::for_each_n(std::forward(exec), fwd1, Get_size(fwd1), FUNCTION{}); + (void) std::find(std::forward(exec), fwd1, fwd1, VAL); + (void) std::find_if(std::forward(exec), fwd1, fwd1, PRED{}); + (void) std::find_if_not(std::forward(exec), fwd1, fwd1, PRED{}); + (void) std::adjacent_find(std::forward(exec), fwd1, fwd1); + (void) std::adjacent_find(std::forward(exec), fwd1, fwd1, BIPRED{}); + (void) std::count(std::forward(exec), fwd1, fwd1, VAL); + (void) std::count_if(std::forward(exec), fwd1, fwd1, PRED{}); + (void) std::search_n(std::forward(exec), fwd1, fwd1, Get_size(fwd1), VAL); + (void) std::search_n(std::forward(exec), fwd1, fwd1, Get_size(fwd1), VAL, BIPRED{}); + std::replace(std::forward(exec), fwd1, fwd1, VAL, VAL); + std::replace_if(std::forward(exec), fwd1, fwd1, PRED{}, VAL); + std::fill(std::forward(exec), fwd1, fwd1, VAL); + std::fill_n(std::forward(exec), fwd1, Get_size(fwd1), VAL); + std::generate(std::forward(exec), fwd1, fwd1, GENERATOR{}); + std::generate_n(std::forward(exec), fwd1, Get_size(fwd1), GENERATOR{}); + (void) std::remove(std::forward(exec), fwd1, fwd1, VAL); + (void) std::remove_if(std::forward(exec), fwd1, fwd1, PRED{}); + (void) std::unique(std::forward(exec), fwd1, fwd1); + (void) std::unique(std::forward(exec), fwd1, fwd1, COMP{}); + std::rotate(std::forward(exec), fwd1, fwd1, fwd1); + + std::partial_sort_copy(std::forward(exec), fwd1, fwd1, RANIT, RANIT); + std::partial_sort_copy(std::forward(exec), fwd1, fwd1, RANIT, RANIT, COMP{}); + (void) std::is_sorted(std::forward(exec), fwd1, fwd1); + (void) std::is_sorted(std::forward(exec), fwd1, fwd1, COMP{}); + (void) std::is_sorted_until(std::forward(exec), fwd1, fwd1); + (void) std::is_sorted_until(std::forward(exec), fwd1, fwd1, COMP{}); + +#if _HAS_CXX20 + std::shift_left(std::forward(exec), fwd1, fwd1, 42); + std::shift_right(std::forward(exec), fwd1, fwd1, 42); +#endif // _HAS_CXX20 + + std::partition(std::forward(exec), fwd1, fwd1, PRED{}); + (void) std::is_partitioned(std::forward(exec), fwd1, fwd1, PRED{}); + + (void) std::min_element(std::forward(exec), fwd1, fwd1); + (void) std::min_element(std::forward(exec), fwd1, fwd1, COMP{}); + (void) std::max_element(std::forward(exec), fwd1, fwd1); + (void) std::max_element(std::forward(exec), fwd1, fwd1, COMP{}); + (void) std::minmax_element(std::forward(exec), fwd1, fwd1); + (void) std::minmax_element(std::forward(exec), fwd1, fwd1, COMP{}); + + (void) std::reduce(std::forward(exec), fwd1, fwd1); + (void) std::reduce(std::forward(exec), fwd1, fwd1, VAL); + (void) std::reduce(std::forward(exec), fwd1, fwd1, VAL, BINARYOP{}); + (void) std::transform_reduce(std::forward(exec), fwd1, fwd1, VAL, BINARYOP{}, UNARYOP{}); + } +#endif // HAS_PARALLEL_ALGORITHMS + + template + void test_fwd1(identity_t fwd1) { + // SPLIT_MODE 2 +#if HAS_PARALLEL_ALGORITHMS + test_exec_fwd1(std::execution::seq, fwd1); + test_exec_fwd1(std::execution::par, fwd1); + test_exec_fwd1(std::execution::par_unseq, fwd1); +#endif // HAS_PARALLEL_ALGORITHMS + + test_fwd1_fwd2(fwd1, FWDIT); + test_fwd1_fwd2(fwd1, BIDIT); + test_fwd1_fwd2(fwd1, RANIT); + test_fwd1_fwd2(fwd1, ARRIT); + + test_fwd1_out(fwd1, OUTIT); + test_fwd1_out(fwd1, INIT); + test_fwd1_out(fwd1, FWDIT); + test_fwd1_out(fwd1, BIDIT); + test_fwd1_out(fwd1, RANIT); + test_fwd1_out(fwd1, ARRIT); + + (void) std::adjacent_find(fwd1, fwd1); + (void) std::adjacent_find(fwd1, fwd1, BIPRED{}); + (void) std::search_n(fwd1, fwd1, Get_size(fwd1), VAL); + (void) std::search_n(fwd1, fwd1, Get_size(fwd1), VAL, BIPRED{}); + std::replace(fwd1, fwd1, VAL, VAL); + std::replace_if(fwd1, fwd1, PRED{}, VAL); + std::fill(fwd1, fwd1, VAL); + std::generate(fwd1, fwd1, GENERATOR{}); + (void) std::remove(fwd1, fwd1, VAL); + (void) std::remove_if(fwd1, fwd1, PRED{}); + (void) std::unique(fwd1, fwd1); + (void) std::unique(fwd1, fwd1, BIPRED{}); + std::rotate(fwd1, fwd1, fwd1); + +#if _HAS_CXX20 + std::shift_left(fwd1, fwd1, 42); + std::shift_right(fwd1, fwd1, 42); +#endif // _HAS_CXX20 + + std::partition(fwd1, fwd1, PRED{}); + (void) std::partition_point(fwd1, fwd1, PRED{}); + (void) std::is_sorted(fwd1, fwd1); + (void) std::is_sorted(fwd1, fwd1, COMP{}); + (void) std::is_sorted_until(fwd1, fwd1); + (void) std::is_sorted_until(fwd1, fwd1, COMP{}); + (void) std::lower_bound(fwd1, fwd1, VAL); + (void) std::lower_bound(fwd1, fwd1, VAL, COMP{}); + (void) std::upper_bound(fwd1, fwd1, VAL); + (void) std::upper_bound(fwd1, fwd1, VAL, COMP{}); + (void) std::equal_range(fwd1, fwd1, VAL); + (void) std::equal_range(fwd1, fwd1, VAL, COMP{}); + (void) std::binary_search(fwd1, fwd1, VAL); + (void) std::binary_search(fwd1, fwd1, VAL, COMP{}); + (void) std::min_element(fwd1, fwd1); + (void) std::min_element(fwd1, fwd1, COMP{}); + (void) std::max_element(fwd1, fwd1); + (void) std::max_element(fwd1, fwd1, COMP{}); + (void) std::minmax_element(fwd1, fwd1); + (void) std::minmax_element(fwd1, fwd1, COMP{}); + + std::iota(fwd1, fwd1, VAL); + +#if _HAS_CXX17 + std::uninitialized_default_construct(fwd1, fwd1); + std::uninitialized_default_construct_n(fwd1, Get_size(fwd1)); + + std::uninitialized_value_construct(fwd1, fwd1); + std::uninitialized_value_construct_n(fwd1, Get_size(fwd1)); +#endif // _HAS_CXX17 + + std::uninitialized_fill(fwd1, fwd1, VAL); + std::uninitialized_fill_n(fwd1, Get_size(fwd1), VAL); + +#if _HAS_CXX17 + std::destroy(fwd1, fwd1); + std::destroy_n(fwd1, Get_size(fwd1)); +#endif // _HAS_CXX17 + } + +#if HAS_PARALLEL_ALGORITHMS + template + void test_exec_bid1_bid2_xxx_backward(ExecutionPolicy&& exec, identity_t bid1, identity_t bid2) { + // SPLIT_MODE 2 + std::copy_backward(std::forward(exec), bid1, bid1, bid2); + std::move_backward(std::forward(exec), bid1, bid1, bid2); + } +#endif // HAS_PARALLEL_ALGORITHMS + + template + void test_bid1_bid2_xxx_backward(identity_t bid1, identity_t bid2) { + // SPLIT_MODE 2 +#if HAS_PARALLEL_ALGORITHMS + test_exec_bid1_bid2_xxx_backward(std::execution::seq, bid1, bid2); + test_exec_bid1_bid2_xxx_backward(std::execution::par, bid1, bid2); + test_exec_bid1_bid2_xxx_backward(std::execution::par_unseq, bid1, bid2); +#endif // HAS_PARALLEL_ALGORITHMS + + std::copy_backward(bid1, bid1, bid2); + std::move_backward(bid1, bid1, bid2); + } + + template + void test_bid1_out(identity_t bid1, identity_t out) { + // SPLIT_MODE 2 + std::reverse_copy(bid1, bid1, out); + } + +#if HAS_PARALLEL_ALGORITHMS + template + void test_exec_bid1_fwd1(ExecutionPolicy&& exec, identity_t bid1, identity_t fwd1) { + std::reverse_copy(std::forward(exec), bid1, bid1, fwd1); + } + + template + void test_bid1_fwd1(identity_t bid1, identity_t fwd1) { + test_exec_bid1_fwd1(std::execution::seq, bid1, fwd1); + test_exec_bid1_fwd1(std::execution::par, bid1, fwd1); + test_exec_bid1_fwd1(std::execution::par_unseq, bid1, fwd1); + } + + template + void test_exec_bid1(ExecutionPolicy&& exec, identity_t bid1) { + std::reverse(std::forward(exec), bid1, bid1); + // Currently the standard requires random-access iterators for stable_sort, but our implementation + // works with bidirectional iterators and we don't want to regress this. + std::stable_sort(std::forward(exec), bid1, bid1); + std::stable_sort(std::forward(exec), bid1, bid1, COMP{}); + std::stable_partition(std::forward(exec), bid1, bid1, PRED{}); + std::inplace_merge(std::forward(exec), bid1, bid1, bid1); + std::inplace_merge(std::forward(exec), bid1, bid1, bid1, COMP{}); + } +#endif // HAS_PARALLEL_ALGORITHMS + + template + void test_bid1(identity_t bid1) { + // SPLIT_MODE 2 + test_bid1_bid2_xxx_backward(bid1, BIDIT); + test_bid1_bid2_xxx_backward(bid1, RANIT); + // copy_backward and move_backward don't have _ITERATOR_DEBUG_ARRAY_OVERLOADS, so the destination + // argument must not be an array or we trigger _SCL_INSECURE_DEPRECATE_FN. + // test_bid1_bid2_xxx_backward(bid1, ARRIT); + + test_bid1_out(bid1, OUTIT); + test_bid1_out(bid1, INIT); + test_bid1_out(bid1, FWDIT); + test_bid1_out(bid1, BIDIT); + test_bid1_out(bid1, RANIT); + test_bid1_out(bid1, ARRIT); + +#if HAS_PARALLEL_ALGORITHMS + test_bid1_fwd1(bid1, FWDIT); + test_bid1_fwd1(bid1, BIDIT); + test_bid1_fwd1(bid1, RANIT); + test_bid1_fwd1(bid1, ARRIT); + + test_exec_bid1(std::execution::seq, bid1); + test_exec_bid1(std::execution::par, bid1); + test_exec_bid1(std::execution::par_unseq, bid1); +#endif // HAS_PARALLEL_ALGORITHMS + + std::reverse(bid1, bid1); + // Currently the standard requires random-access iterators for stable_sort, but our implementation + // works with bidirectional iterators and we don't want to regress this. + std::stable_sort(bid1, bid1); + std::stable_sort(bid1, bid1, COMP{}); + std::stable_partition(bid1, bid1, PRED{}); + std::inplace_merge(bid1, bid1, bid1); + std::inplace_merge(bid1, bid1, bid1, COMP{}); + std::next_permutation(bid1, bid1); + std::next_permutation(bid1, bid1, COMP{}); + std::prev_permutation(bid1, bid1); + std::prev_permutation(bid1, bid1, COMP{}); + } + + + template + void test_out(identity_t out) { + // SPLIT_MODE 1 + std::fill_n(out, 0, VAL); + std::generate_n(out, 0, GENERATOR{}); + } + +#if HAS_PARALLEL_ALGORITHMS + template + void test_exec_ran(ExecutionPolicy&& exec, identity_t ran) { + std::sort(std::forward(exec), ran, ran); + std::sort(std::forward(exec), ran, ran, COMP{}); + std::partial_sort(std::forward(exec), ran, ran, ran); + std::partial_sort(std::forward(exec), ran, ran, ran, COMP{}); + std::nth_element(std::forward(exec), ran, ran, ran); + std::nth_element(std::forward(exec), ran, ran, ran, COMP{}); + (void) std::is_heap(std::forward(exec), ran, ran); + (void) std::is_heap(std::forward(exec), ran, ran, COMP{}); + (void) std::is_heap_until(std::forward(exec), ran, ran); + (void) std::is_heap_until(std::forward(exec), ran, ran, COMP{}); + } +#endif // HAS_PARALLEL_ALGORITHMS + + template + void test_ran(identity_t ran) { + // SPLIT_MODE 1 +#if HAS_PARALLEL_ALGORITHMS + test_exec_ran(std::execution::seq, ran); + test_exec_ran(std::execution::par, ran); + test_exec_ran(std::execution::par_unseq, ran); +#endif // HAS_PARALLEL_ALGORITHMS + +#if _HAS_AUTO_PTR_ETC + std::random_shuffle(ran, ran); + std::random_shuffle(ran, ran, RNG{}); +#endif // _HAS_AUTO_PTR_ETC + std::shuffle(ran, ran, URNG{}); + std::sort(ran, ran); + std::sort(ran, ran, COMP{}); + std::partial_sort(ran, ran, ran); + std::partial_sort(ran, ran, ran, COMP{}); + std::nth_element(ran, ran, ran); + std::nth_element(ran, ran, ran, COMP{}); + std::push_heap(ran, ran); + std::push_heap(ran, ran, COMP{}); + std::pop_heap(ran, ran); + std::pop_heap(ran, ran, COMP{}); + std::make_heap(ran, ran); + std::make_heap(ran, ran, COMP{}); + std::sort_heap(ran, ran); + std::sort_heap(ran, ran, COMP{}); + (void) std::is_heap(ran, ran); + (void) std::is_heap(ran, ran, COMP{}); + (void) std::is_heap_until(ran, ran); + (void) std::is_heap_until(ran, ran, COMP{}); + } + + + void test() { + test_in1(INIT); + test_in1(FWDIT); + test_in1(BIDIT); + test_in1(RANIT); + test_in1(ARRIT); + +#if INSTANTIATE_ALGORITHMS_SPLIT_MODE == 2 + test_fwd1(FWDIT); + test_fwd1(BIDIT); + test_fwd1(RANIT); + test_fwd1(ARRIT); + + test_bid1(BIDIT); + test_bid1(RANIT); + test_bid1(ARRIT); +#endif // SPLIT_MODE + +#if INSTANTIATE_ALGORITHMS_SPLIT_MODE == 1 + test_out(OUTIT); + test_out(INIT); + test_out(FWDIT); + test_out(BIDIT); + test_out(RANIT); + test_out(ARRIT); + + test_ran(RANIT); + test_ran(ARRIT); + + LST.merge(LST); + LST.merge(std::move(LST)); + LST.merge(LST, COMP{}); + LST.merge(std::move(LST), COMP{}); + LST.remove(VAL); + LST.remove_if(PRED{}); + LST.reverse(); + LST.sort(); + LST.sort(COMP{}); + LST.splice(LST.end(), LST); + LST.splice(LST.end(), std::move(LST)); + LST.splice(LST.end(), LST, LST.begin()); + LST.splice(LST.end(), std::move(LST), LST.begin()); + LST.splice(LST.end(), LST, LST.begin(), LST.end()); + LST.splice(LST.end(), std::move(LST), LST.begin(), LST.end()); + LST.unique(); + LST.unique(COMP{}); + (void) (LST == LST); + + FLST.merge(FLST); + FLST.merge(std::move(FLST)); + FLST.merge(FLST, COMP{}); + FLST.merge(std::move(FLST), COMP{}); + FLST.remove(VAL); + FLST.remove_if(PRED{}); + FLST.reverse(); + FLST.sort(); + FLST.sort(COMP{}); + FLST.splice_after(FLST.end(), FLST); + FLST.splice_after(FLST.end(), std::move(FLST)); + FLST.splice_after(FLST.end(), FLST, FLST.begin()); + FLST.splice_after(FLST.end(), std::move(FLST), FLST.begin()); + FLST.splice_after(FLST.end(), FLST, FLST.begin(), FLST.end()); + FLST.splice_after(FLST.end(), std::move(FLST), FLST.begin(), FLST.end()); + FLST.unique(); + FLST.unique(COMP{}); + (void) (FLST == FLST); + + (void) std::min(VAL, VAL); + (void) std::min(VAL, VAL, COMP{}); + (void) std::min({VAL, VAL, VAL}); + (void) std::min({VAL, VAL, VAL}, COMP{}); + (void) std::max(VAL, VAL); + (void) std::max(VAL, VAL, COMP{}); + (void) std::max({VAL, VAL, VAL}); + (void) std::max({VAL, VAL, VAL}, COMP{}); +#if _HAS_CXX17 + (void) std::clamp(VAL, VAL, VAL); + (void) std::clamp(VAL, VAL, VAL, COMP{}); +#endif // _HAS_CXX17 + (void) std::minmax(VAL, VAL); + (void) std::minmax(VAL, VAL, COMP{}); + (void) std::minmax({VAL, VAL, VAL}); + (void) std::minmax({VAL, VAL, VAL}, COMP{}); +#endif // SPLIT_MODE + } + }; + + template , typename BIPRED = dummy_functors::BiPredicate, + typename UNARYOP = dummy_functors::UnaryOperation, + typename BINARYOP = dummy_functors::BinaryOperation, + typename GENERATOR = dummy_functors::Generator, + typename FUNCTION = dummy_functors::Function, typename RNG = dummy_functors::Rng, + typename URNG = dummy_functors::Urng> + void instantiate_std_algorithms_with(InIt a, FwdIt b, BidIt c, RanIt d, OutIt e) { + algorithms_tester + test_algorithms{a, b, c, d, e}; + test_algorithms.test(); + } +} // namespace std_testing diff --git a/tests/std/include/instantiate_algorithms_int.hpp b/tests/std/include/instantiate_algorithms_int.hpp new file mode 100644 index 00000000000..e8ebc5a1c48 --- /dev/null +++ b/tests/std/include/instantiate_algorithms_int.hpp @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +// This header contains all code for the instantiate_algorithms_int* test cases. +// The instantiate_algorithm* tests take too long individually, so must be split into two parts. + +#include +#include + +void test() { + std_testing::input_iterator_container input_it{}; + std::forward_list fwd_it{}; + std::list bidi_it{}; + std::vector rand_it{}; + + std_testing::instantiate_std_algorithms_with( + input_it.begin(), fwd_it.begin(), bidi_it.begin(), rand_it.begin(), std::front_inserter(fwd_it)); +} diff --git a/tests/std/include/instantiate_algorithms_nontrivial.hpp b/tests/std/include/instantiate_algorithms_nontrivial.hpp new file mode 100644 index 00000000000..8c700cc7582 --- /dev/null +++ b/tests/std/include/instantiate_algorithms_nontrivial.hpp @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +// This header contains all code for the instantiate_algorithms_nontrivial* test cases. +// The instantiate_algorithm* tests take too long individually, so must be split into two parts. + +#include +#include +#include +#include + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +// This is a type whose constructors and destructor are all non-trivial, +// since we support some optimizations for trivial types. +struct NonTrivialType { + NonTrivialType() : m_data(get_random()) {} + ~NonTrivialType() { + m_data = get_random(); + } + NonTrivialType(const NonTrivialType&) : m_data(get_random()) {} + + NonTrivialType& operator=(const NonTrivialType&) { + m_data = get_random(); + return *this; + } + + bool operator<(const NonTrivialType&) const { + return false; + } + bool operator==(const NonTrivialType&) const { + return true; + } + + NonTrivialType operator+(const NonTrivialType& v) const { + return v; + } + NonTrivialType operator-(const NonTrivialType& v) const { + return v; + } + NonTrivialType operator*(const NonTrivialType& v) const { + return v; + } + + NonTrivialType& operator++() { + return *this; + } + + unsigned int get_random() { + std::random_device get_rand{}; + return get_rand(); + } + + unsigned int m_data; +}; + +STATIC_ASSERT(!std::is_trivially_default_constructible_v); +STATIC_ASSERT(!std::is_trivially_copy_constructible_v); +STATIC_ASSERT(!std::is_trivially_move_constructible_v); +STATIC_ASSERT(!std::is_trivially_destructible_v); +STATIC_ASSERT(!std::is_trivially_copy_assignable_v); +STATIC_ASSERT(!std::is_trivially_move_assignable_v); + +void test() { + std_testing::input_iterator_container input_it{}; + std::forward_list fwd_it{}; + std::list bidi_it{}; + std::vector rand_it{}; + + std_testing::instantiate_std_algorithms_with( + input_it.begin(), fwd_it.begin(), bidi_it.begin(), rand_it.begin(), std::front_inserter(fwd_it)); +} + +#undef STATIC_ASSERT diff --git a/tests/std/include/instantiate_algorithms_op_deref.hpp b/tests/std/include/instantiate_algorithms_op_deref.hpp new file mode 100644 index 00000000000..4ec4e0435e6 --- /dev/null +++ b/tests/std/include/instantiate_algorithms_op_deref.hpp @@ -0,0 +1,342 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +// This header contains all code for the instantiate_algorithms_op_deref* test cases. +// The instantiate_algorithm* tests take too long individually, so must be split into two parts. + +#include + +// DevDiv#758138 "Several algorithms break with iterators that overload the comma operator." +// DevDiv#758134 "uninitialized_copy and uninitialized_copy_n break with classes that overload operator &." + +// ADL will search this namespace for op,(). +namespace Meow { + + // This is an evil element type that overloads op&(). + // It supports various operations required by various algorithms. + struct Evil { + void operator&() const = delete; + + bool operator<(const Evil&) const { + return false; + } + bool operator==(const Evil&) const { + return true; + } + + Evil operator+(const Evil& e) const { + return e; + } + Evil operator-(const Evil& e) const { + return e; + } + Evil operator*(const Evil& e) const { + return e; + } + + Evil& operator++() { + return *this; + } + }; + + // These iterators point to Evil elements and will activate the op,() below. + template + struct BasicInIt { + using iterator_category = std::input_iterator_tag; + using value_type = Evil; + using difference_type = test_difference_type; + using pointer = Evil*; + using reference = Evil&; + + BasicInIt(int, int) {} + BasicInIt(const BasicInIt&) = default; + BasicInIt(BasicInIt&&) = default; + BasicInIt& operator=(const BasicInIt&) = default; + BasicInIt& operator=(BasicInIt&&) = default; + ~BasicInIt() = default; + + Evil& operator*() const { + static Evil val{}; + return val; + } + Evil* operator->() const { + return nullptr; + } + BasicInIt& operator++() { + return *this; + } + void operator++(int) = delete; // avoid postincrement + bool operator==(const BasicInIt&) const { + return true; + } + bool operator!=(const BasicInIt&) const { + return true; + } + + void _Seek_to(BasicInIt) {} + + BasicInIt _Unwrapped() const { + return BasicInIt{11, 22}; + } + + static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0; + }; + + template + struct BasicFwdIt { + using iterator_category = std::forward_iterator_tag; + using value_type = Evil; + using difference_type = test_difference_type; + using pointer = Evil*; + using reference = Evil&; + + BasicFwdIt() = default; + BasicFwdIt(const BasicFwdIt&) = default; + BasicFwdIt(BasicFwdIt&&) = default; + BasicFwdIt& operator=(const BasicFwdIt&) = default; + BasicFwdIt& operator=(BasicFwdIt&&) = default; + ~BasicFwdIt() = default; + + Evil& operator*() const { + static Evil val{}; + return val; + } + Evil* operator->() const { + return nullptr; + } + BasicFwdIt& operator++() { + return *this; + } + void operator++(int) = delete; // avoid postincrement + bool operator==(const BasicFwdIt&) const { + return true; + } + bool operator!=(const BasicFwdIt&) const { + return true; + } + + void _Seek_to(BasicFwdIt) {} + + BasicFwdIt _Unwrapped() const { + return BasicFwdIt{}; + } + + static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0; + }; + + template + struct BasicBidIt { + using iterator_category = std::bidirectional_iterator_tag; + using value_type = Evil; + using difference_type = test_difference_type; + using pointer = Evil*; + using reference = Evil&; + + BasicBidIt() = default; + BasicBidIt(const BasicBidIt&) = default; + BasicBidIt(BasicBidIt&&) = default; + BasicBidIt& operator=(const BasicBidIt&) = default; + BasicBidIt& operator=(BasicBidIt&&) = default; + ~BasicBidIt() = default; + + Evil& operator*() const { + static Evil val{}; + return val; + } + Evil* operator->() const { + return nullptr; + } + BasicBidIt& operator++() { + return *this; + } + void operator++(int) = delete; // avoid postincrement + bool operator==(const BasicBidIt&) const { + return true; + } + bool operator!=(const BasicBidIt&) const { + return true; + } + + BasicBidIt& operator--() { + return *this; + } + void operator--(int) = delete; // avoid postdecrement + + + void _Seek_to(BasicBidIt) {} + + BasicBidIt _Unwrapped() const { + return BasicBidIt{}; + } + + static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0; + }; + + template + struct BasicRanIt { + using iterator_category = std::random_access_iterator_tag; + using value_type = Evil; + using difference_type = test_difference_type; + using pointer = Evil*; + using reference = Evil&; + + BasicRanIt() = default; + BasicRanIt(const BasicRanIt&) = default; + BasicRanIt(BasicRanIt&&) = default; + BasicRanIt& operator=(const BasicRanIt&) = default; + BasicRanIt& operator=(BasicRanIt&&) = default; + ~BasicRanIt() = default; + + Evil& operator*() const { + static Evil val{}; + return val; + } + Evil* operator->() const { + return nullptr; + } + BasicRanIt& operator++() { + return *this; + } + void operator++(int) = delete; // avoid postincrement + bool operator==(const BasicRanIt&) const { + return true; + } + bool operator!=(const BasicRanIt&) const { + return true; + } + BasicRanIt& operator--() { + return *this; + } + void operator--(int) = delete; // avoid postdecrement + + BasicRanIt& operator+=(difference_type) { + return *this; + } + BasicRanIt& operator-=(difference_type) { + return *this; + } + BasicRanIt operator+(difference_type) const { + return *this; + } + BasicRanIt operator-(difference_type) const { + return *this; + } + difference_type operator-(const BasicRanIt&) const { + return 0; + } + + Evil& operator[](difference_type) const = delete; // avoid subscript, N4849 [algorithms.requirements]/8 + + bool operator<(const BasicRanIt&) const { + return true; + } + bool operator<=(const BasicRanIt&) const { + return true; + } + bool operator>(const BasicRanIt&) const { + return true; + } + bool operator>=(const BasicRanIt&) const { + return true; + } + + void _Seek_to(BasicRanIt) {} + + BasicRanIt _Unwrapped() const { + return BasicRanIt{}; + } + + static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0; + +#if _ITERATOR_DEBUG_LEVEL != 0 + void _Verify_offset(difference_type) const {} +#endif // _ITERATOR_DEBUG_LEVEL != 0 + }; + + template + BasicRanIt operator+(test_difference_type, const BasicRanIt& i) { + return i; + } + + template + struct BasicOutIt { + using iterator_category = std::output_iterator_tag; + using value_type = void; + using difference_type = void; + using pointer = void; + using reference = void; + + BasicOutIt(int, int) {} + BasicOutIt(const BasicOutIt&) = default; + BasicOutIt(BasicOutIt&&) = default; + BasicOutIt& operator=(const BasicOutIt&) = default; + BasicOutIt& operator=(BasicOutIt&&) = default; + ~BasicOutIt() = default; + + Evil& operator*() const { + static Evil val{}; + return val; + } + BasicOutIt& operator++() { + return *this; + } + void operator++(int) = delete; // avoid postincrement + + + void _Seek_to(BasicOutIt) {} + + BasicOutIt _Unwrapped() const { + return BasicOutIt{11, 22}; + } + + static constexpr bool _Unwrap_when_unverified = _ITERATOR_DEBUG_LEVEL == 0; + }; + + // If it's dragged in via ADL, this op,() will absorb anything. + template + void operator,(const T&, const U&) = delete; + + // VSO-258601 "std::vector should not rely on operator& in Debug mode" + // If it's dragged in via ADL, this op&() will absorb anything. + template + void operator&(const T&) = delete; + +} // namespace Meow + +void test() { + // Test with iterators which have overloaded comma operator. + std_testing::instantiate_std_algorithms_with(Meow::BasicInIt{11, 22}, Meow::BasicFwdIt{}, + Meow::BasicBidIt{}, Meow::BasicRanIt{}, Meow::BasicOutIt{11, 22}); +} + +// Also test DevDiv#938759 ": is_assignable should tolerate overloaded comma operators [libcxx]". +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +STATIC_ASSERT(std::is_assignable_v); +STATIC_ASSERT(!std::is_assignable_v); + +#undef STATIC_ASSERT + +#if _HAS_CXX17 +#include + +// Defend against regression of the "," operator in optional::value +void test_optional() { + using Meow::Evil; + using std::optional; + { + optional oe{Evil()}; + (void) oe.value(); + } + { + const optional oe{Evil()}; + (void) oe.value(); + } + { (void) optional{Evil()}.value(); } + { + using T = const optional; + (void) T{Evil()}.value(); + } +} +#endif // _HAS_CXX17 diff --git a/tests/std/include/instantiate_containers_iterators_common.hpp b/tests/std/include/instantiate_containers_iterators_common.hpp new file mode 100644 index 00000000000..edf4e75680d --- /dev/null +++ b/tests/std/include/instantiate_containers_iterators_common.hpp @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// lets INSTANTIATE macro be used for types that aren't default constructible. +// Doesn't actually instantiate the type if not default constructible, +// but it will inspect the type, which is the true purpose. +template > +struct instantiate_helper; + +template +struct instantiate_helper { + using type = T; +}; + +template +struct instantiate_helper { + using type = int; +}; + +#define USE_VALUE(...) \ + do { \ + auto val = __VA_ARGS__; \ + (void) val; \ + } while (0) +#define INSTANTIATE(...) \ + do { \ + typename instantiate_helper<__VA_ARGS__>::type val{}; \ + (void) val; \ + } while (0) +#define TRAIT_V(TRAIT_NAME, ...) USE_VALUE(TRAIT_NAME##_v<__VA_ARGS__>) + +// need to prefer copy constructor over default constructor so iterator comparison is valid. +template +std::enable_if_t, T> construct_another(const T& value) { + return value; +} + +template +std::enable_if_t, T> construct_another(const T&) { + return T{}; +} + +template +void equality_test(T&& lhs, U&& rhs) { + USE_VALUE(lhs == rhs); + USE_VALUE(lhs != rhs); +} + +template +void equality_test(T value) { + T another = construct_another(value); + equality_test(value, another); +} + +template +void comparable_test(T&& lhs, U&& rhs) { + equality_test(lhs, rhs); + USE_VALUE(lhs < rhs); + USE_VALUE(lhs > rhs); + USE_VALUE(lhs <= rhs); + USE_VALUE(lhs >= rhs); +} + +template +void comparable_test(T value) { + T another = construct_another(value); + comparable_test(value, another); +} + +template +void swap_test(const T& value) { + T lhs = construct_another(value); + T rhs = construct_another(value); + std::swap(lhs, rhs); +} + +template +void hash_test(T&& value) { + auto hasher = std::hash>(); + (void) hasher(std::forward(value)); +} + +template +void hash_test() { + T value{}; + auto hasher = std::hash(); + (void) hasher(value); +} + +template +void fwd_iterators_test() { + using ValueType = typename Container::value_type; + Container c{static_cast(1), static_cast(2), static_cast(3), + static_cast(4), static_cast(5), static_cast(6), static_cast(7), + static_cast(8), static_cast(9), static_cast(10)}; + + auto it = begin(c); + auto it2 = it; + + INSTANTIATE(std::iterator_traits); + (void) next(it); + advance(it2, 5); + (void) distance(it, it2); + + USE_VALUE(make_move_iterator(it)); + swap_test(it); +} + +template +void bidi_iterators_test() { + using ValueType = typename Container::value_type; + Container c{static_cast(1), static_cast(2), static_cast(3), + static_cast(4), static_cast(5), static_cast(6), static_cast(7), + static_cast(8), static_cast(9), static_cast(10)}; + auto it = begin(c); + equality_test(it); + auto rit = end(c); + equality_test(rit); + (void) prev(next(it)); +} + +template +void random_access_iterator_test(T value) { + typename std::iterator_traits::difference_type diff{}; + USE_VALUE(diff + value); + USE_VALUE(value - value); + comparable_test(value); + ++value; + value++; + --value; + value--; +} + +template +void random_iterators_test() { + using ValueType = typename Container::value_type; + Container c{static_cast(1), static_cast(2), static_cast(3), + static_cast(4), static_cast(5), static_cast(6), static_cast(7), + static_cast(8), static_cast(9), static_cast(10)}; + random_access_iterator_test(c.begin()); + random_access_iterator_test(c.rbegin()); +} + +template +auto get_all_iterator_types_for(T value) { + using value_type = typename T::value_type; + + return std::make_tuple(std_testing::input_iterator_container(begin(value), end(value)), + std::forward_list(begin(value), end(value)), std::list(begin(value), end(value)), + std::vector(begin(value), end(value))); +} diff --git a/tests/std/include/parallel_algorithms_utilities.hpp b/tests/std/include/parallel_algorithms_utilities.hpp new file mode 100644 index 00000000000..888ef91d000 --- /dev/null +++ b/tests/std/include/parallel_algorithms_utilities.hpp @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +#include +#include +#include + +#ifdef EXHAUSTIVE +const size_t max_parallel_test_case_n = 1000; +#else // ^^^ EXHAUSTIVE ^^^ // vvv !EXHAUSTIVE vvv +const size_t max_parallel_test_case_n = std::max(4u, std::thread::hardware_concurrency()) + 1; +#endif // EXHAUSTIVE + +template +void parallel_test_case(Fx fn, Args&... vals) { + // call fn with "interesting" test case sizes and additional parameters +#ifdef EXHAUSTIVE + for (size_t testSize = 0; testSize < max_parallel_test_case_n; ++testSize) { +#else // ^^^ EXHAUSTIVE ^^^ // vvv !EXHAUSTIVE vvv + static const size_t cases[] = { + 0, 1, 2, max_parallel_test_case_n - 2, max_parallel_test_case_n - 1, max_parallel_test_case_n}; + for (size_t testSize : cases) { +#endif // EXHAUSTIVE + fn(testSize, vals...); + } +} diff --git a/tests/std/include/test_death.hpp b/tests/std/include/test_death.hpp new file mode 100644 index 00000000000..d88e73fc951 --- /dev/null +++ b/tests/std/include/test_death.hpp @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +#include +#include +#include +#include +#include +#include +#include + +namespace std_testing { + + constexpr int internal_failure = 103; + using normal_function_t = void (*)(); + using death_function_t = void (*)(); + + [[noreturn]] inline void api_unexpected(const char* const api_name) { + const auto last_error = static_cast(::GetLastError()); + printf("%s failed; LastError: 0x%08X\n", api_name, last_error); + abort(); + } + + + class death_test_executive { + const normal_function_t run_normal_tests; + std::vector death_tests; + + int execute_death_test(const char* const test_id) const { + const auto testId = static_cast(atoi(test_id)); + + if (errno == 0) { + _set_abort_behavior(0, _WRITE_ABORT_MSG); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); + + death_tests[testId](); + return 0; + } else { + puts("failed to parse test_id"); + return internal_failure; + } + } + + DWORD dispatch_death_test(const size_t test_id, const wchar_t* const this_program) const { + STARTUPINFOW si{}; + si.cb = sizeof(si); + + PROCESS_INFORMATION pi{}; + + std::wstring test_id_str(1, L' '); + test_id_str.append(std::to_wstring(test_id)); + if (::CreateProcessW(this_program, &test_id_str[0], nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi) + == 0) { + api_unexpected("CreateProcessW"); + } + + if (::WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_OBJECT_0) { + api_unexpected("WaitForSingleObject"); + } + + DWORD exit_code = 0; + if (::GetExitCodeProcess(pi.hProcess, &exit_code) == 0) { + api_unexpected("GetExitCodeProcess"); + } + + ::CloseHandle(pi.hThread); + ::CloseHandle(pi.hProcess); + + return exit_code; + } + + static std::wstring get_current_process_path() { + std::wstring result(MAX_PATH, L'\0'); + for (;;) { + const DWORD result_size = ::GetModuleFileNameW(nullptr, &result[0], static_cast(result.size())); + const size_t str_size = result.size(); + if (result_size == str_size) { + // buffer was not big enough + const size_t str_max_size = result.max_size(); + const size_t result_max_size = str_max_size - str_max_size / 2; + if (result_size >= result_max_size) { + api_unexpected("GetModuleFileNameW"); + } + + result.resize(result_size + result_size / 2); + } else if (result_size == 0) { + api_unexpected("GetModuleFileNameW"); + } else { + result.resize(result_size); + break; + } + } + + return result; + } + + public: + explicit death_test_executive(const normal_function_t normal_tests_function) + : run_normal_tests(normal_tests_function) {} + + + template + void add_death_tests(const death_function_t (&tests)[TestsCount]) { + death_tests.insert(death_tests.end(), tests, std::end(tests)); + } + + int run(int argc, char* argv[]) const { + if (argc == 1) { + // first pass, run normal tests and sub-process loop + printf("running normal tests..."); + run_normal_tests(); + puts(" passed!"); + + ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); + const auto this_program = get_current_process_path(); + const size_t death_tests_size = death_tests.size(); + for (size_t idx = 0; idx < death_tests_size; ++idx) { + printf("running death test %zu... ", idx); + const DWORD death_test_result = dispatch_death_test(idx, this_program.c_str()); + if (death_test_result <= 1000U) { + printf("returned %lu", death_test_result); + } else { + printf("returned 0x%lX", death_test_result); + } + + if (death_test_result == 0 || death_test_result == 100) { + puts(", a success code (this is bad)"); + puts("Terminate!"); + return 1; + } else if (death_test_result == internal_failure) { + puts(", an internal test harness failure"); + puts("Terminate!"); + return 1; + } else { + puts(", a failure code (this is good)"); + } + } + + return 0; + } else if (argc == 2) { + return execute_death_test(argv[1]); + } else { + puts("incorrect command line"); + return 1; + } + } + }; +} // namespace std_testing diff --git a/tests/std/include/test_filesystem_support.hpp b/tests/std/include/test_filesystem_support.hpp new file mode 100644 index 00000000000..4abe1848eb2 --- /dev/null +++ b/tests/std/include/test_filesystem_support.hpp @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once + +#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING + +#include +#include +#include +#include +#include +#include +#include + +inline std::string get_test_directory_subname(const char* const testName, const size_t testNameLength) { + using namespace std; + random_device rd; + uniform_int_distribution<> dist(0, 15); + string subName(testName, testNameLength); + subName.push_back('_'); + generate_n(back_inserter(subName), 16, [&] { return "0123456789ABCDEF"[dist(rd)]; }); + return subName; +} + +inline std::experimental::filesystem::path get_test_directory(const char* const testName) { + return std::experimental::filesystem::temp_directory_path() + / get_test_directory_subname(testName, strlen(testName)); +} + +#if _HAS_CXX17 +#include + +inline std::filesystem::path get_new_test_directory(std::string_view testName) { + return std::filesystem::temp_directory_path() / get_test_directory_subname(testName.data(), testName.size()); +} +#endif // _HAS_CXX17 diff --git a/tests/std/include/test_regex_support.hpp b/tests/std/include/test_regex_support.hpp new file mode 100644 index 00000000000..c4a5802c831 --- /dev/null +++ b/tests/std/include/test_regex_support.hpp @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +#include +#include +#include + +class regex_fixture { + int regex_test_result = 0; + +public: + int result() const { + return regex_test_result; + } + + void fail_regex() { + regex_test_result = 1; + } + + void verify(const bool b) { + if (!b) { + fail_regex(); + } + } + + void verify_match_regex(const std::string& subject, const std::string& pattern, const std::regex& r, + const std::regex_constants::syntax_option_type syntax, const bool correct) { + try { + if (std::regex_match(subject, r) != correct) { + printf(R"(Expected regex_match("%s", regex("%s", 0x%X)) to be %s.)" + "\n", + subject.c_str(), pattern.c_str(), static_cast(syntax), correct ? "true" : "false"); + fail_regex(); + } + } catch (const std::regex_error& e) { + printf(R"(Failed to regex_match("%s", regex("%s", 0x%X)): regex_error: "%s")" + "\n", + subject.c_str(), pattern.c_str(), static_cast(syntax), e.what()); + fail_regex(); + } + } + + void verify_match_impl(const std::string& subject, const std::string& pattern, + const std::regex_constants::syntax_option_type syntax, const bool correct) { + try { + const std::regex r(pattern, syntax); + verify_match_regex(subject, pattern, r, syntax, correct); + } catch (const std::regex_error& e) { + printf(R"(Failed to construct regex("%s", 0x%X): "%s")" + "\n", + pattern.c_str(), static_cast(syntax), e.what()); + fail_regex(); + } + } + + void should_match(const std::string& subject, const std::string& pattern, + const std::regex_constants::syntax_option_type syntax = std::regex_constants::ECMAScript) { + verify_match_impl(subject, pattern, syntax, true); + } + + void should_match(const std::string& subject, const std::string& pattern, const std::regex& regex, + const std::regex_constants::syntax_option_type syntax = std::regex_constants::ECMAScript) { + verify_match_regex(subject, pattern, regex, syntax, true); + } + + void should_not_match(const std::string& subject, const std::string& pattern, + const std::regex_constants::syntax_option_type syntax = std::regex_constants::ECMAScript) { + verify_match_impl(subject, pattern, syntax, false); + } + + void should_not_match(const std::string& subject, const std::string& pattern, const std::regex& regex, + const std::regex_constants::syntax_option_type syntax = std::regex_constants::ECMAScript) { + verify_match_regex(subject, pattern, regex, syntax, false); + } + + void should_capture(const std::string& subject, const std::string& pattern, const std::string& group) { + try { + const std::regex r(pattern); + std::smatch m; + + if (!std::regex_match(subject, m, r)) { + printf(R"(Expected regex("%s") to match "%s".)" + "\n", + pattern.c_str(), subject.c_str()); + fail_regex(); + return; + } + + if (m.size() != 2) { + printf(R"(should_capture("%s", "%s", "%s"): bad group count (%zu))" + "\n", + subject.c_str(), pattern.c_str(), group.c_str(), m.size()); + fail_regex(); + return; + } + + if (m[0] != subject) { + printf(R"(should_capture("%s", "%s", "%s"): m[0] == "%s")" + "\n", + subject.c_str(), pattern.c_str(), group.c_str(), m[0].str().c_str()); + fail_regex(); + } + + if (m[1] != group) { + printf(R"(should_capture("%s", "%s", "%s"): m[1] == "%s")" + "\n", + subject.c_str(), pattern.c_str(), group.c_str(), m[1].str().c_str()); + fail_regex(); + } + } catch (const std::regex_error& e) { + printf(R"(should_capture("%s", "%s", "%s"): regex_error: "%s")" + "\n", + subject.c_str(), pattern.c_str(), group.c_str(), e.what()); + fail_regex(); + } + } + + void should_replace_to(const std::string& subject, const std::string& pattern, const std::string& fmt, + const std::regex_constants::match_flag_type match_flags, const std::string& expected) { + try { + const std::regex r(pattern); + + const std::string result = std::regex_replace(subject, r, fmt, match_flags); + if (result != expected) { + printf("should_replace_to(\n" + R"(subject: "%s")" + "\n" + R"(pattern: "%s")" + "\n" + R"(fmt: "%s")" + "\n" + R"(match_flags: 0x%X)" + "\n" + R"(expected: "%s")" + "\n" + R"(): bad answer, returned: "%s")" + "\n", + subject.c_str(), pattern.c_str(), fmt.c_str(), static_cast(match_flags), + expected.c_str(), result.c_str()); + fail_regex(); + } + } catch (const std::regex_error& e) { + printf("should_replace_to(\n" + R"(subject: "%s")" + "\n" + R"(pattern: "%s")" + "\n" + R"(fmt: "%s")" + "\n" + R"(match_flags: 0x%X)" + "\n" + R"(expected: "%s")" + "\n" + R"(): regex_error: "%s")" + "\n", + subject.c_str(), pattern.c_str(), fmt.c_str(), static_cast(match_flags), expected.c_str(), + e.what()); + fail_regex(); + } + } + + void should_throw(const std::string& pattern, const std::regex_constants::error_type expectedCode) { + try { + const std::regex r(pattern); + printf(R"(regex r("%s") succeeded (which is bad).)" + "\n", + pattern.c_str()); + fail_regex(); + } catch (const std::regex_error& e) { + if (e.code() != expectedCode) { + printf(R"(regex r("%s") threw 0x%X; expected 0x%X)" + "\n", + pattern.c_str(), static_cast(e.code()), static_cast(expectedCode)); + fail_regex(); + } + } + } +}; + +class test_regex { + regex_fixture* const fixture; + const std::string pattern; + const std::regex_constants::syntax_option_type syntax; + const std::regex r; + +public: + test_regex(regex_fixture* fixture, const std::string& pattern, + std::regex_constants::syntax_option_type syntax = std::regex_constants::ECMAScript) + : fixture(fixture), pattern(pattern), syntax(syntax), r(pattern, syntax) {} + + test_regex(const test_regex&) = delete; + test_regex& operator=(const test_regex&) = delete; + + void should_search_match(const std::string& subject, const std::string& expected, + const std::regex_constants::match_flag_type match_flags = std::regex_constants::match_default) const { + std::smatch mr; + try { + const bool search_result = std::regex_search(subject, mr, r, match_flags); + if (!search_result || mr[0] != expected) { + printf(R"(Expected regex_search("%s", regex("%s", 0x%X), 0x%X) to find "%s", )", subject.c_str(), + pattern.c_str(), static_cast(syntax), static_cast(match_flags), + expected.c_str()); + if (search_result) { + printf(R"(but it matched "%s")" + "\n", + mr.str().c_str()); + } else { + puts("but it failed to match"); + } + + fixture->fail_regex(); + } + } catch (const std::regex_error& e) { + printf(R"(Failed to regex_search("%s", regex("%s", 0x%X), 0x%X): regex_error: "%s")" + "\n", + subject.c_str(), pattern.c_str(), static_cast(syntax), + static_cast(match_flags), e.what()); + fixture->fail_regex(); + } + } + + void should_search_fail(const std::string& subject, + const std::regex_constants::match_flag_type match_flags = std::regex_constants::match_default) const { + std::smatch mr; + try { + if (std::regex_search(subject, mr, r, match_flags)) { + printf(R"(Expected regex_search("%s", regex("%s", 0x%X), 0x%X) to not match, but it found "%s")" + "\n", + subject.c_str(), pattern.c_str(), static_cast(syntax), + static_cast(match_flags), mr.str().c_str()); + fixture->fail_regex(); + } + } catch (const std::regex_error& e) { + printf(R"(Failed to regex_search("%s", regex("%s", 0x%X), 0x%X): regex_error: "%s")" + "\n", + subject.c_str(), pattern.c_str(), static_cast(syntax), + static_cast(match_flags), e.what()); + fixture->fail_regex(); + } + } +}; diff --git a/tests/std/include/test_thread_support.hpp b/tests/std/include/test_thread_support.hpp new file mode 100644 index 00000000000..d147ccf13f1 --- /dev/null +++ b/tests/std/include/test_thread_support.hpp @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once + +#include +#include +#include +#include +#include +#include +#ifdef _MSC_EXTENSIONS +#include +#endif // _MSC_EXTENSIONS + +class one_shot { + bool unblock = false; + std::mutex mtx; + std::condition_variable cv; + +public: + template + bool wait_for(const std::chrono::duration& dur) { + std::unique_lock lck(this->mtx); + return this->cv.wait_for(lck, dur, [this] { return this->unblock; }); + } + + void fire() { + { + std::lock_guard lck(this->mtx); + if (this->unblock) { + return; + } + + this->unblock = true; + } + + this->cv.notify_all(); + } +}; + +class watchdog { + one_shot os; + std::thread t; + + static void kill() { + fprintf(stdout, "Terminating test due to watchdog timeout.\n"); + fflush(stdout); + _Exit(1); + } + + static void kill_if_not_debugging() { +#ifdef _MSC_EXTENSIONS + if (::IsDebuggerPresent()) { + fprintf(stdout, "Watchdog not terminating because debugger is connected.\n"); + fflush(stdout); + } else { + kill(); + } +#else // ^^^ _MSC_EXTENSIONS ^^^ // vvv !_MSC_EXTENSIONS vvv + kill(); +#endif // _MSC_EXTENSIONS + } + +public: + template + explicit watchdog(const std::chrono::duration& dur) + : os(), t([dur, this]() { + if (!this->os.wait_for(dur)) { + kill_if_not_debugging(); + } + }) {} + + void muzzle() { + this->os.fire(); + } + + ~watchdog() { + this->muzzle(); + this->t.join(); + } +}; diff --git a/tests/std/include/test_windows.h b/tests/std/include/test_windows.h new file mode 100644 index 00000000000..aecb1ac36b4 --- /dev/null +++ b/tests/std/include/test_windows.h @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +struct IUnknown; // windows.h drags in a template that uses IUnknown before it has been declared. +#include diff --git a/tests/std/run.pl b/tests/std/run.pl new file mode 100644 index 00000000000..e1995885020 --- /dev/null +++ b/tests/std/run.pl @@ -0,0 +1,45 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +use strict; +use File::Basename; + +# This file is part of a Microsoft-internal legacy test harness, which we hope to replace in the future. +# Within the Microsoft-internal repo, this uses run.pl and run.pm in src\qa\VC\shared\testenv\bin . + +my $path = $ENV{PATH}; +$path =~ s/\//\\/g; + +# pick out just *:*\testenv\bin from the path +$path =~ m/.*?([^\;]*\\testenv\\bin)($|\\$|\\;|;).*/i; + +my $testenv = $1; +my $testdir = dirname($0); # $0 contains the full path including the filename, dirname($0) extracts the directory path. + +# add testenv to perllib so we don't have to search for it in other files. +if ($ENV{PERLLIB}) +{ + $ENV{PERLLIB} = $ENV{PERLLIB} . ";" . $testenv; +} +else +{ + $ENV{PERLLIB} = $testenv; +} + +if ($ENV{PM_COMPILER} && $ENV{PM_COMPILER} eq "clang-cl" && $ENV{CLANG_TARGET} && $ENV{CLANG_TARGET} =~ /^(-m32|-m64)$/) +{ + $ENV{PM_COMPILER} .= " " . $ENV{CLANG_TARGET}; +} + +my $RunPL = ""; +if ($ENV{PM_CL} && $ENV{PM_CL} =~ m/[\-\/]BE / ) +{ + $RunPL = $testdir . "\\runbe.pl"; +} +else +{ + $RunPL = $testenv . "\\run.pl"; +} + +print "Executing: \"$RunPL\"\n"; +exit(system("perl -w $RunPL")>>8); diff --git a/tests/std/runbe.pl b/tests/std/runbe.pl new file mode 100644 index 00000000000..f57ec0be2a6 --- /dev/null +++ b/tests/std/runbe.pl @@ -0,0 +1,23 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +use strict; +use Run; + +if ($ENV{HAS_EDG} && $ENV{HAS_EDG} eq "yes") +{ + my $callString = Run::CreateCompilandString(); + + if (Run::ExecuteCL($callString) == 0) + { + Run::Pass(); + } + else + { + Run::Fail(); + } +} +else +{ + Run::Pass(); +} diff --git a/tests/std/test.lst b/tests/std/test.lst new file mode 100644 index 00000000000..877bf774bc4 --- /dev/null +++ b/tests/std/test.lst @@ -0,0 +1,321 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +tests\Dev08_496675_iostream_int_reading +tests\Dev08_527068_scl_no_exceptions +tests\Dev08_563686_ostream +tests\Dev08_563705_std_malloc_free +tests\Dev08_576265_list_remove +tests\Dev08_584299_search_n +tests\Dev09_012361_vector_swap +tests\Dev09_052961_has_iterator_debugging_0 +tests\Dev09_056375_locale_cleanup +tests\Dev09_098637_stl_function_typeids +tests\Dev09_119637_throwing_string_with_hid0 +tests\Dev09_119644_compiler_option_gz +tests\Dev09_126254_persistent_aux_allocators +tests\Dev09_130060_unique_copy +tests\Dev09_152755_tr1_nested_bind +tests\Dev09_153419_tr1_allocators +tests\Dev09_154033_tr1_predicate_search_n +tests\Dev09_155328_tr1_vector_of_set +tests\Dev09_158181_tr1_unordered_meow_swap +tests\Dev09_158457_tr1_mem_fn_calling_conventions +tests\Dev09_161106_tr1_bind_templated_fxn_call_operator +tests\Dev09_165853_tr1_tuple_swap +tests\Dev09_171205_tr1_assign_pair_to_tuple +tests\Dev09_172497_tr1_mem_fn_const_correctness +tests\Dev09_172505_tr1_bind_reference_wrapper +tests\Dev09_172666_tr1_tuple_odr +tests\Dev09_173612_tr1_regex_leak +tests\Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer +tests\Dev09_175314_tr1_reference_wrapper_assignment +tests\Dev09_175716_tr1_dereferencing_reference_wrapper +tests\Dev09_176467_tr1_make_tuple_from_string_literal +tests\Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops +tests\Dev09_181509_tr1_inf_loop_uniform_int_ull +tests\Dev09_182017_tr1_search_n +tests\Dev09_186118_stoullx_corner_cases +tests\Dev09_192736_tr1_prngs_not_copyconstructible +tests\Dev09_195561_tr1_function_const_op +tests\Dev09_196243_tr1_enable_shared_from_this_ops +tests\Dev09_199123_tr1_mem_fun_abstract_classes +tests\Dev10_391723_bind_result_type +tests\Dev10_414242_facet_bug_use_facet_ctype_char +tests\Dev10_441756_function_reference_wrapper +tests\Dev10_445289_make_shared +tests\Dev10_470547_facet_bug_stringstream +tests\Dev10_482830_header_only_string +tests\Dev10_491486_floating_point_hash +tests\Dev10_492345_tr1_function_swap +tests\Dev10_498944_enable_shared_from_this_auto_ptr +tests\Dev10_500860_overloaded_address_of +tests\Dev10_544258_heterogeneous_comparisons +tests\Dev10_555491_complex_linker_errors +tests\Dev10_561430_list_and_tree_leaks +tests\Dev10_562056_tree_leak +tests\Dev10_563443_empty_vector_begin_plus_zero +tests\Dev10_567556_move_from_empty_list +tests\Dev10_579381_vector_grow_to +tests\Dev10_590599_hash_string +tests\Dev10_609053_ctype_char_table_size +tests\Dev10_617014_tuple_tie +tests\Dev10_632876_regex_proxy +tests\Dev10_635436_shared_ptr_reset +tests\Dev10_639436_const_map_at +tests\Dev10_646244_bad_alloc_message +tests\Dev10_646556_construct_tuple_from_const +tests\Dev10_654977_655012_shared_ptr_move +tests\Dev10_661739_tuple_copy_ctors +tests\Dev10_682964_stable_sort_warnings +tests\Dev10_689595_back_inserter_vector_bool +tests\Dev10_709166_checked_and_unchecked_array_iterator +tests\Dev10_709168_marking_iterators_as_checked +tests\Dev10_722102_shared_ptr_nullptr +tests\Dev10_729003_bind_reference_wrapper +tests\Dev10_766948_insert_ambiguity +tests\Dev10_780098_movable_elements +tests\Dev10_783436_rvalue_string_plus +tests\Dev10_809142_copy_n_istream_iterator +tests\Dev10_814245_regex_character_class_crash +tests\Dev10_816787_swap_vector_bool_elements +tests\Dev10_847656_shared_ptr_is_convertible +tests\Dev10_851347_weak_ptr_virtual_inheritance +tests\Dev10_860410_bitset_ctors +tests\Dev10_860421_deque_push_back_pop_front +tests\Dev10_881629_vector_erase_return_value +tests\Dev10_904413_moved_from_function_should_be_empty +tests\Dev10_905461_is_sorted_until +tests\Dev10_908702_string_memory_leak +tests\Dev10_909646_stringstream_vd2 +tests\Dev11_0000000_dual_range_algorithms +tests\Dev11_0000000_function_crashes +tests\Dev11_0000000_include_each_header_alone +tests\Dev11_0000000_null_forward_iterators +tests\Dev11_0000000_quoted +tests\Dev11_0000000_rotate_test +tests\Dev11_0000000_tuple_cat +tests\Dev11_0000000_user_defined_literals +tests\Dev11_0019127_singular_iterators +tests\Dev11_0091392_string_erase_resize_perf +tests\Dev11_0133625_locale0_implib_cpp +tests\Dev11_0135139_vector_bool_equality_perf +tests\Dev11_0235721_async_and_packaged_task +tests\Dev11_0253803_debug_pointer +tests\Dev11_0272959_make_signed +tests\Dev11_0289403_partition_point_complexity +tests\Dev11_0299014_exception_ptr_requirements +tests\Dev11_0302476_pair_move +tests\Dev11_0314451_make_pair_make_tuple +tests\Dev11_0316853_find_memchr_optimization +tests\Dev11_0343056_pair_tuple_ctor_sfinae +tests\Dev11_0376122_grand_theft_bind +tests\Dev11_0377755_thread_ctor_move_only_types +tests\Dev11_0387701_container_equality +tests\Dev11_0417110_nullptr_t_is_scalar +tests\Dev11_0435439_call_once_deadlock +tests\Dev11_0437519_container_behavior +tests\Dev11_0437519_container_requirements +tests\Dev11_0447546_facet_allocation +tests\Dev11_0453373_codecvt_compiles +tests\Dev11_0483851_vector_debug_allocator_use +tests\Dev11_0485243_condition_variable_crash +tests\Dev11_0493504_error_category_lifetime +tests\Dev11_0494593_time_put_wchar_t +tests\Dev11_0496153_locale_ctor +tests\Dev11_0532622_minmax_element +tests\Dev11_0535636_functional_overhaul +tests\Dev11_0555154_system_clock_to_time_t +tests\Dev11_0577418_random_seed_0 +tests\Dev11_0579795_inplace_merge_out_of_memory +tests\Dev11_0607540_pair_tuple_rvalue_references +tests\Dev11_0617384_empty_std_function +tests\Dev11_0653897_codecvt_partial +tests\Dev11_0671816_list_splice +tests\Dev11_0696045_future_wait_for +tests\Dev11_0704582_ratio +tests\Dev11_0732166_unordered_strong_guarantee +tests\Dev11_0748972_function_crash_out_of_memory +tests\Dev11_0823534_transparent_lookup +tests\Dev11_0835323_to_string +tests\Dev11_0836436_get_time +tests\Dev11_0845312_comprehensive_floating_point +tests\Dev11_0863628_atomic_compare_exchange +tests\Dev11_0920385_list_sort_allocator +tests\Dev11_1003120_search_test +tests\Dev11_1066589_shared_ptr_atomic_deadlock +tests\Dev11_1066931_filesystem_rename_noop +tests\Dev11_1074023_constexpr +tests\Dev11_1086953_call_once_overhaul +tests\Dev11_1114006_condition_variable_pred +tests\Dev11_1127004_future_has_exceptions_0 +tests\Dev11_1131212_uncaught_exceptions +tests\Dev11_1137366_nested_exception +tests\Dev11_1140665_unique_ptr_array_conversions +tests\Dev11_1150223_shared_mutex +tests\Dev11_1158803_regex_thread_safety +tests\Dev11_1180290_filesystem_error_code +tests\GH_000457_system_error_message +tests\P0024R2_parallel_algorithms_adjacent_difference +tests\P0024R2_parallel_algorithms_adjacent_find +tests\P0024R2_parallel_algorithms_all_of +tests\P0024R2_parallel_algorithms_count +tests\P0024R2_parallel_algorithms_equal +tests\P0024R2_parallel_algorithms_exclusive_scan +tests\P0024R2_parallel_algorithms_find +tests\P0024R2_parallel_algorithms_find_end +tests\P0024R2_parallel_algorithms_find_first_of +tests\P0024R2_parallel_algorithms_for_each +tests\P0024R2_parallel_algorithms_inclusive_scan +tests\P0024R2_parallel_algorithms_is_heap +tests\P0024R2_parallel_algorithms_is_partitioned +tests\P0024R2_parallel_algorithms_is_sorted +tests\P0024R2_parallel_algorithms_mismatch +tests\P0024R2_parallel_algorithms_partition +tests\P0024R2_parallel_algorithms_reduce +tests\P0024R2_parallel_algorithms_remove +tests\P0024R2_parallel_algorithms_replace +tests\P0024R2_parallel_algorithms_search +tests\P0024R2_parallel_algorithms_search_n +tests\P0024R2_parallel_algorithms_set_difference +tests\P0024R2_parallel_algorithms_set_intersection +tests\P0024R2_parallel_algorithms_sort +tests\P0024R2_parallel_algorithms_stable_sort +tests\P0024R2_parallel_algorithms_transform +tests\P0024R2_parallel_algorithms_transform_exclusive_scan +tests\P0024R2_parallel_algorithms_transform_inclusive_scan +tests\P0024R2_parallel_algorithms_transform_reduce +tests\P0035R4_over_aligned_allocation +tests\P0040R3_extending_memory_management_tools +tests\P0067R5_charconv +tests\P0083R3_splicing_maps_and_sets +tests\P0088R3_variant +tests\P0092R1_polishing_chrono +tests\P0122R7_span +tests\P0122R7_span_death +tests\P0137R1_launder +tests\P0156R2_scoped_lock +tests\P0202R3_constexpr_algorithm_and_exchange +tests\P0218R1_filesystem +tests\P0220R1_any +tests\P0220R1_optional +tests\P0220R1_polymorphic_memory_resources +tests\P0220R1_sample +tests\P0220R1_searchers +tests\P0220R1_string_view +tests\P0325R4_to_array +tests\P0356R5_bind_front +tests\P0357R3_supporting_incomplete_types_in_reference_wrapper +tests\P0414R2_shared_ptr_for_arrays +tests\P0426R1_constexpr_char_traits +tests\P0433R2_deduction_guides +tests\P0487R1_fixing_operator_shl_basic_istream_char_pointer +tests\P0513R0_poisoning_the_hash +tests\P0553R4_bit_rotating_and_counting_functions +tests\P0556R3_bit_ispow2_ceil2_floor2_log2p1 +tests\P0595R2_is_constant_evaluated +tests\P0607R0_inline_variables +tests\P0616R0_using_move_in_numeric +tests\P0631R8_numbers_math_constants +tests\P0674R1_make_shared_for_arrays +tests\P0758R1_is_nothrow_convertible +tests\P0768R1_spaceship_operator +tests\P0769R2_shift_left_shift_right +tests\P0811R3_midpoint_lerp +tests\P0896R4_ranges_iterator_machinery +tests\P0896R4_ranges_range_machinery +tests\P0896R4_ranges_to_address +tests\P0898R3_concepts +tests\P0898R3_identity +tests\P0919R3_heterogeneous_unordered_lookup +tests\P0966R1_string_reserve_should_not_shrink +tests\P1165R1_consistently_propagating_stateful_allocators +tests\P1423R3_char8_t_remediation +tests\P1645R1_constexpr_numeric +tests\VSO_0000000_allocator_propagation +tests\VSO_0000000_any_calling_conventions +tests\VSO_0000000_c_math_functions +tests\VSO_0000000_condition_variable_any_exceptions +tests\VSO_0000000_container_allocator_constructors +tests\VSO_0000000_exception_ptr_rethrow_seh +tests\VSO_0000000_fancy_pointers +tests\VSO_0000000_has_static_rtti +tests\VSO_0000000_initialize_everything +tests\VSO_0000000_instantiate_algorithms_16_difference_type_1 +tests\VSO_0000000_instantiate_algorithms_16_difference_type_2 +tests\VSO_0000000_instantiate_algorithms_32_difference_type_1 +tests\VSO_0000000_instantiate_algorithms_32_difference_type_2 +tests\VSO_0000000_instantiate_algorithms_64_difference_type_1 +tests\VSO_0000000_instantiate_algorithms_64_difference_type_2 +tests\VSO_0000000_instantiate_algorithms_int_1 +tests\VSO_0000000_instantiate_algorithms_int_2 +tests\VSO_0000000_instantiate_algorithms_nontrivial_1 +tests\VSO_0000000_instantiate_algorithms_nontrivial_2 +tests\VSO_0000000_instantiate_containers +tests\VSO_0000000_instantiate_cvt +tests\VSO_0000000_instantiate_iterators_misc +tests\VSO_0000000_instantiate_type_traits +tests\VSO_0000000_list_iterator_debugging +tests\VSO_0000000_list_unique_self_reference +tests\VSO_0000000_matching_npos_address +tests\VSO_0000000_more_pair_tuple_sfinae +tests\VSO_0000000_nullptr_stream_out +tests\VSO_0000000_oss_workarounds +tests\VSO_0000000_path_stream_parameter +tests\VSO_0000000_regex_interface +tests\VSO_0000000_regex_use +tests\VSO_0000000_strengthened_noexcept +tests\VSO_0000000_string_view_idl +tests\VSO_0000000_type_traits +tests\VSO_0000000_vector_algorithms +tests\VSO_0000000_wcfb01_idempotent_container_destructors +tests\VSO_0000000_wchar_t_filebuf_xsmeown +tests\VSO_0095468_clr_exception_ptr_bad_alloc +tests\VSO_0095837_current_exception_dtor +tests\VSO_0099869_pow_float_overflow +tests\VSO_0102478_moving_allocators +tests\VSO_0104705_throwing_copy_in_current_exception +tests\VSO_0104705_throwing_copy_in_current_exception_seh +tests\VSO_0105317_expression_sfinae +tests\VSO_0118461_min_max_noexcept +tests\VSO_0121275_filesystem_canonical_should_handle_many_double_dots +tests\VSO_0121440_is_iterator_iterator_traits +tests\VSO_0131167_associative_emplacement_allocations +tests\VSO_0135428_custom_char_traits_string +tests\VSO_0144114_sleep_until +tests\VSO_0144294_unordered_map_max_bucket_count +tests\VSO_0149983_system_error_broken_pipe +tests\VSO_0157762_feature_test_macros +tests\VSO_0174871_string_replace +tests\VSO_0180466_algorithm_overhauls +tests\VSO_0180469_fill_family +tests\VSO_0180469_ptr_cat +tests\VSO_0191296_allocator_construct +tests\VSO_0204655_heap_algorithms_integer_overflow +tests\VSO_0224478_scoped_allocator +tests\VSO_0226079_mutex +tests\VSO_0234888_num_get_overflows +tests\VSO_0299624_checked_array_iterator_idl +tests\VSO_0397980_codecvt_length +tests\VSO_0429900_fast_debug_range_based_for +tests\VSO_0474901_shift_jis_codecvt +tests\VSO_0493909_is_aggregate +tests\VSO_0512710_terminate_current_exception_from_noexcept_function +tests\VSO_0512710_terminate_current_exception_from_noexcept_function_2 +tests\VSO_0512710_terminate_current_exception_from_unwind +tests\VSO_0527559_pragma_managed +tests\VSO_0575109_string_ambiguous_overloads +tests\VSO_0599804_seekg_zero +tests\VSO_0644691_utf_8_codecvt +tests\VSO_0663136_string_includes_cctype +tests\VSO_0664587_lcg_divide_by_zero +tests\VSO_0677157_flist_merge_edge_cases +tests\VSO_0735700_fstream_read_over_4k +tests\VSO_0736657_unordered_assign_rehash +tests\VSO_0744055_atomic_load_8_bytes_readonly +tests\VSO_0792651_unordered_set_rehash_invalidates_key +tests\VSO_0830211_container_debugging_range_checks +tests\VSO_0849827_multicontainer_emplace_hint_position +tests\VSO_0938757_attribute_order +tests\VSO_0961751_hash_range_erase +tests\VSO_0971246_legacy_await_headers diff --git a/tests/std/tests/Dev08_496675_iostream_int_reading/env.lst b/tests/std/tests/Dev08_496675_iostream_int_reading/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev08_496675_iostream_int_reading/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev08_496675_iostream_int_reading/test.cpp b/tests/std/tests/Dev08_496675_iostream_int_reading/test.cpp new file mode 100644 index 00000000000..475d9ca2692 --- /dev/null +++ b/tests/std/tests/Dev08_496675_iostream_int_reading/test.cpp @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +int main() { + { + std::stringstream ss; + int i = 0; + + // the C locale should not have any numeric grouping defined, + // so the comma after 2 should not be confused with a thousand + // separator. + ss << "2,"; + + // imbueing the "C" locale workaround the problem + // ss.imbue(std::locale("C")); + + // reading from the stream should not fail + assert(ss >> i); + } + + { + // test for floats + + std::stringstream ss; + float f = 0; + + // the C locale should not have any numeric grouping defined, + // so the comma after 2 should not be confused with a thousand + // separator. + ss << "2,"; + + // reading from the stream should not fail + assert(ss >> f); + } +} diff --git a/tests/std/tests/Dev08_527068_scl_no_exceptions/env.lst b/tests/std/tests/Dev08_527068_scl_no_exceptions/env.lst new file mode 100644 index 00000000000..a7497cef718 --- /dev/null +++ b/tests/std/tests/Dev08_527068_scl_no_exceptions/env.lst @@ -0,0 +1,7 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\native_matrix.lst +RUNALL_CROSSLIST +PM_CL="/D_HAS_EXCEPTIONS=0" +PM_CL="/D_HAS_EXCEPTIONS=1" diff --git a/tests/std/tests/Dev08_527068_scl_no_exceptions/test.cpp b/tests/std/tests/Dev08_527068_scl_no_exceptions/test.cpp new file mode 100644 index 00000000000..518e6c44901 --- /dev/null +++ b/tests/std/tests/Dev08_527068_scl_no_exceptions/test.cpp @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +////////////////////////////////////////////////////////////////////////////////////////// + +// Bug : VSW527068 +// The Standard c++ library fails to compile when +// 1) _HAS_EXCEPTIONS=0 +// AND +// 2) "exception" is included as one of the header files + + +// Problem : +// When _HAS_EXCEPTIONS=0, the header defines another std::exception class which +// conflicts with the regular (_HAS_EXCEPTIONS=1) std::exception. The fix was +// to move the std::exception class into stdext namespace and use +// "using stdext::exception;" to pull it into the std namespace when _HAS_EXCEPTIONS=0. + + +// Test : +// Make sure all the combinations of _HAS_EXCEPTIONS=0|1, /MD[d] /MT[d], and +// _STATIC compiles. +// +// Make sure that std::exception is defined when _HAS_EXCEPTIONS is both 0 and 1. +// +// Make sure that stdext::exception is defined when _HAS_EXCEPTIONS is 1. + +////////////////////////////////////////////////////////////////////////////////////////// + +// compile with: /EHsc + +// VSO-115482 - Include first to ensure when _HAS_EXCEPTIONS=0, it doesn't emit any errors without including +// beforehand. +#include + +// This comment prevents clang-format from reordering below the other headers. + +#include +#include + +int main() {} // COMPILE-ONLY + +// VSO-115482 - Ensure type_info is in namespace std when _HAS_EXCEPTIONS=0. +using check_typeinfo = std::type_info; + +void MyFunc() { + _THROW(std::exception("this is an exception")); +} + +void __cdecl handler(const std::exception& e) { + std::cout << "in handler, exception: " << e.what() << std::endl; +} + +void meow() { +#if !_HAS_EXCEPTIONS + stdext::exception::_Set_raise_handler(&handler); +#endif + _TRY_BEGIN + std::cout << "In try block, calling MyFunc()." << std::endl; + MyFunc(); + _CATCH(std::exception e) +#if _HAS_EXCEPTIONS + std::cout << "In catch handler." << std::endl; + std::cout << "Caught CTest exception type: "; + std::cout << e.what() << std::endl; +#endif + _CATCH_END + std::cout << "Back in main. Execution resumes here." << std::endl; +} diff --git a/tests/std/tests/Dev08_563686_ostream/env.lst b/tests/std/tests/Dev08_563686_ostream/env.lst new file mode 100644 index 00000000000..3b7de8d6fd7 --- /dev/null +++ b/tests/std/tests/Dev08_563686_ostream/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\native_winsdk_matrix.lst diff --git a/tests/std/tests/Dev08_563686_ostream/test.cpp b/tests/std/tests/Dev08_563686_ostream/test.cpp new file mode 100644 index 00000000000..0b855218743 --- /dev/null +++ b/tests/std/tests/Dev08_563686_ostream/test.cpp @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +////////////////////////////////////////////////////////////////////////////////////////// + +// Bug : VSW563686 +// iostream has memory leaks + +// Problem : +// istream and ostream virtually inherits from ios_base. Init function +// was being called from both the derived classes. This resulted in +// a memory leak since the memory allocated in the first initialization +// is lost when the Init function is called the second time. +// +// Fix : +// Modify ostream constructor to take a parameter that specifies whether +// it should call base class. Modify the constructor to call Init based +// on the parameter. + +// Test : +// Use CRT memory tracking functions to detect memory leaks. +// Create iostream instances and destroy them. +// Check for any memory leaks. + +////////////////////////////////////////////////////////////////////////////////////////// + +#define CRTDBG_MAP_ALLOC +#include +#include +#include +#include + +int main() { + // Track CRT blocks + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF); + + { + // Allocate long lived objects in the CRT. + // We don't want these objects to show up as leaks. + std::iostream s(nullptr); + } + + // Get memory state before creating iostream + _CrtMemState before; + _CrtMemCheckpoint(&before); + + // Construct and destroy an iostream, which previously leaked. + { std::iostream s(nullptr); } + + // Get memory state after iostream allocation/deallocation + _CrtMemState after; + _CrtMemCheckpoint(&after); + + // Diff memory state + _CrtMemState diff; + // return 1 if there are diffs + int nRet = _CrtMemDifference(&diff, &before, &after); + (void) diff; + (void) before; + (void) after; + + // Dump diff stats and the leaks if any. + _CrtMemDumpStatistics(&diff); + OutputDebugString("Start Memory Dump\n"); + _CrtMemDumpAllObjectsSince(&before); + OutputDebugString("End Memory Dump\n"); + + return nRet; +} diff --git a/tests/std/tests/Dev08_563705_std_malloc_free/env.lst b/tests/std/tests/Dev08_563705_std_malloc_free/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev08_563705_std_malloc_free/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev08_563705_std_malloc_free/test.cpp b/tests/std/tests/Dev08_563705_std_malloc_free/test.cpp new file mode 100644 index 00000000000..ca2165b62cc --- /dev/null +++ b/tests/std/tests/Dev08_563705_std_malloc_free/test.cpp @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +////////////////////////////////////////////////////////////////////////////////////////// + +// Bug : VSW563705 +// When _CRTDBG_MAP_ALLOC is defined, cpp files that use std::malloc(), +// std::free(), std::calloc(), std::realloc() don't compile. +// + +// Problem : +// When _CRTDBG_MAP_ALLOC is defined, malloc() is defined as _malloc_dbg() etc., but +// _malloc_dbg() isn't defined in std namespace. + +// Test : +// This is a compilation test making sure that std::malloc() etc. can be compiled +// successfully when _CRTDBG_MAP_ALLOC is defined. + + +////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +int main() { + // this is a test to test whether + // malloc/free/realloc and its _dbg variant + // compiles under std namespace + std::free(std::malloc(1)); + std::free(std::calloc(1, 1)); + std::free(std::realloc(std::malloc(1), 1)); +} diff --git a/tests/std/tests/Dev08_576265_list_remove/env.lst b/tests/std/tests/Dev08_576265_list_remove/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev08_576265_list_remove/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev08_576265_list_remove/test.cpp b/tests/std/tests/Dev08_576265_list_remove/test.cpp new file mode 100644 index 00000000000..6604c0e870d --- /dev/null +++ b/tests/std/tests/Dev08_576265_list_remove/test.cpp @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +struct Val { + int value; + unsigned int canary; + Val() : value(0), canary(0xDEADBEEF) {} + Val(int val) : value(val), canary(0x600DF00D) {} + ~Val() { + canary = 0xDEADBEEF; + } +}; + +bool operator==(const Val& val1, const Val& val2) { + assert(val1.canary == 0x600DF00D && val2.canary == 0x600DF00D); + return val1.value == val2.value; +} + +int main() { + // When passed a reference to an element of the list, std::list::remove + // will defer destruction of that element's node until it returns. + std::list l; + + l.push_back(Val(1)); + l.push_back(Val(2)); + l.remove(l.front()); +} diff --git a/tests/std/tests/Dev08_584299_search_n/env.lst b/tests/std/tests/Dev08_584299_search_n/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev08_584299_search_n/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev08_584299_search_n/test.cpp b/tests/std/tests/Dev08_584299_search_n/test.cpp new file mode 100644 index 00000000000..f072ce2925d --- /dev/null +++ b/tests/std/tests/Dev08_584299_search_n/test.cpp @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +// This test makes sure that the search_n algorithm behaves correctly. +// In VS2005, we were incorrectly identifying a shorter sequence as the +// correct result. E.g., in the sequence: + +// 8,7,0,0,1,1,8,0,8,2,1,1,1,0,1,0,2,0,8,0,8,2,37,40 + +// search_n identified the first two zeroes as a sequence of 3 zeroes. + +int main() { + { + // use random access iterators + const int asize = 24; + int a[asize] = {8, 7, 0, 0, 1, 1, 8, 0, 8, 2, 1, 1, 1, 0, 1, 0, 2, 0, 8, 0, 8, 2, 37, 40}; + + const auto res = std::search_n(a, a + asize, 3, 0); + const auto diff = res - a; + assert(diff == 24); + } + + { + // use bidirectional iterators + const int asize = 24; + int a[asize] = {8, 7, 0, 0, 1, 1, 8, 0, 8, 2, 1, 1, 1, 0, 1, 0, 2, 0, 8, 0, 8, 2, 37, 40}; + std::list l; + + for (int i = 0; i < asize; ++i) { + l.push_back(a[i]); + } + const auto res = std::search_n(l.begin(), l.end(), 3, 0); + const auto diff = std::distance(l.begin(), res); + assert(diff == 24); + } +} diff --git a/tests/std/tests/Dev09_012361_vector_swap/env.lst b/tests/std/tests/Dev09_012361_vector_swap/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_012361_vector_swap/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_012361_vector_swap/test.cpp b/tests/std/tests/Dev09_012361_vector_swap/test.cpp new file mode 100644 index 00000000000..1d1487c2150 --- /dev/null +++ b/tests/std/tests/Dev09_012361_vector_swap/test.cpp @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +// DevDiv Bugs.12361 - "VS2005 Checked STL vector::swap causes incorrect iterator assertion in Release builds" + +// C++03 23.1/10 requires that "all container types defined in this clause meet +// the following additional requirements: [...] no swap() function invalidates +// any references, pointers, or iterators referring to the elements of the +// containers being swapped." + +// This was broken when _HAS_ITERATOR_DEBUGGING was disabled and _SECURE_SCL +// was enabled (the default in release mode, obtainable in debug mode). +// In this case, every iterator held a pointer to its parent container (in +// addition to the element being referred to) so that it could perform bounds +// checking. However, swapping containers would not update these parent +// pointers, so using iterators into those containers would perform bounds +// checks against the wrong containers. (Vector iterators perform bounds checks +// based on pointers, not indices, so they were broken even when the containers +// were the same size.) Also, one container could be destroyed before the +// other, wreaking havoc even more reliably. + +// This afflicted all Standard containers (vector/deque/list, set/multiset, +// map/multimap, and string). When both _HAS_ITERATOR_DEBUGGING and _SECURE_SCL +// were enabled, swap() worked properly because the iterator debugging +// machinery walked through all iterators to update their parent container +// pointers. When both _HAS_ITERATOR_DEBUGGING and _SECURE_SCL were disabled, +// there were no parent container pointers to get mangled, with one exception: + +// deque was even more broken. Due to its map-of-blocks structure, deque +// iterators maintained parent container pointers even when both +// _HAS_ITERATOR_DEBUGGING and _SECURE_SCL were disabled. These were also +// broken by swap(). + +// The fix for both of these problems was to introduce a dynamically allocated +// object, called the aux object, owned by every container when +// _HAS_ITERATOR_DEBUGGING is disabled and _SECURE_SCL is enabled (and +// additionally by deque when both _HAS_ITERATOR_DEBUGGING and _SECURE_SCL are +// disabled). An iterator now holds a pointer to an aux object, which holds a +// pointer to a container. This extra level of indirection solves the swap() +// problem; the containers and the aux objects do not change addresses, but +// the containers swap ownership of their aux objects, and the aux objects are +// made to point to their new owners, allowing iterators to find their parents +// correctly. + +// Note, however, that this fix has NOT been applied to strings, because of the +// complexity of how they are passed between the separately compiled runtime +// and the client code. + +// The aux object is allocated by the container's allocator due to a subtle +// issue. When creating a precompiled header, the compiler snapshots its +// internal data structures to disk. These internal data structures include +// STL containers, which use a special allocator to support this snapshotting. +// If the aux object is simply allocated by "new", then it will be missing +// when the PCH is reloaded. + +// This fix has the following effects on container and iterator sizes +// (in 32-bit mode): +// 1. Non-string non-deque containers are 4 bytes larger in release mode with +// _SECURE_SCL enabled (as they must own an aux object now). +// 2. Non-string non-deque containers are the same size in debug mode with +// _HAS_ITERATOR_DEBUGGING disabled. Although they own an aux object now, +// an unnecessary data member was removed, keeping them the same size. +// 3. Non-string non-deque iterators are the same size in release mode with +// _SECURE_SCL enabled (their parent container pointer was replaced with an aux +// object pointer). +// 4. Non-string non-deque iterators are 4 bytes smaller in debug mode with +// _HAS_ITERATOR_DEBUGGING disabled. They gained an aux object pointer, but +// lost two unnecessary data members. + +// 5. Deque iterators are 4 bytes smaller in release mode with _SECURE_SCL +// enabled (a duplicate data member was removed). +// 6. Deque iterators are 8 bytes smaller in debug mode with +// _HAS_ITERATOR_DEBUGGING disabled (three data members were removed, and an +// aux object pointer was added). + +// 7. Deques are 8 bytes larger in release mode (regardless of _SECURE_SCL). +// This is because they must own an aux object now, although I don't know why +// this costs 8 bytes instead of 4. There seems to be padding involved. + +// To summarize object sizes in the order, +// Debug HID/SCL, Debug SCL, Debug None, Release SCL, Release None: +// vector: Previously 20, 20, 20, 16, 16. Now 20, 20, 20, 20, 16. +// vector::iterator: Previously 12, 12, 12, 8, 4. Now 12, 8, 8, 8, 4. +// deque: Previously 28, 28, 28, 20, 20. Now 28, 28, 28, 28, 28. +// deque::iterator: Previously 12, 16, 16, 12, 8. Now 12, 8, 8, 8, 8. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +template +void test_swap(const char* const name) { + const size_t N = sizeof(C); + + unsigned char array[N] = {0}; + + C c; + c.insert(c.end(), 10); + c.insert(c.end(), 20); + c.insert(c.end(), 30); + + C* const p = new (array) C; + _Analysis_assume_(p); + p->insert(p->end(), 11); + p->insert(p->end(), 22); + p->insert(p->end(), 33); + p->insert(p->end(), 44); + p->insert(p->end(), 55); + + typename C::const_iterator i = p->begin(); + + advance(i, 3); + + swap(c, *p); + + p->~C(); + memset(array, 0xC4, N); + + assert(*i == 44); + + printf(" * %s test succeeded.\n", name); +} + +int main() { +#ifdef _DEBUG +#if _HAS_ITERATOR_DEBUGGING + puts("Running tests for Debug HID/SCL."); +#elif _SECURE_SCL + puts("Running tests for Debug SCL."); +#else + puts("Running tests for Debug None."); +#endif +#else +#if _SECURE_SCL + puts("Running tests for Retail SCL."); +#else + puts("Running tests for Retail None."); +#endif +#endif + + test_swap>("vector"); + test_swap>("deque"); + test_swap>("list"); + test_swap>("set"); + + puts("All tests succeeded."); +} diff --git a/tests/std/tests/Dev09_052961_has_iterator_debugging_0/env.lst b/tests/std/tests/Dev09_052961_has_iterator_debugging_0/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_052961_has_iterator_debugging_0/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_052961_has_iterator_debugging_0/test.cpp b/tests/std/tests/Dev09_052961_has_iterator_debugging_0/test.cpp new file mode 100644 index 00000000000..cead3da600f --- /dev/null +++ b/tests/std/tests/Dev09_052961_has_iterator_debugging_0/test.cpp @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +// DevDiv Bugs.52961 - "VC8 SP1 Regression: Crash With /MDd /D_HAS_ITERATOR_DEBUGGING=0" +// +// This regression from VC8 RTM to VC8 SP1 affects code compiled in debug mode +// with iterator debugging disabled. Whenever an iterator is set to point into +// a container and then the container is destroyed before the iterator, the code +// will crash. +// +// This was caused by the fix for the VC8 RTM bug VSWhidbey.579198, which also +// affected debug mode with iterator debugging disabled. In that bug, we begin +// with a local std::string, which has iterator debugging disabled. We then call +// std::string::substr(), which runs inside the separately compiled msvcp100d.dll +// with iterator debugging ENABLED and returns a temporary std::string with iterator +// debugging ENABLED. We then call std::string::end() on the temporary, which also +// runs inside the DLL. When this method constructs its return value, the iterator +// is registered in the temporary std::string's iterator list. However, the iterator +// will be destroyed in the user's code, which has iterator debugging disabled. +// Therefore, the temporary std::string's iterator list is left with an entry for +// a dead iterator. When the temporary std::string itself dies, its destructor runs +// in the DLL and detects that it was created with iterator debugging ENABLED, so +// it attempts to orphan all iterators in its iterator list, and tries to write to +// wherever the dead iterator lived. +// +// The fix introduced code into the base of all iterators (not just string iterators) +// which would run in user code compiled in debug mode with iterator debugging disabled +// and detect if the dying iterator was created inside the DLL with iterator debugging +// ENABLED, in which case the iterator would remove itself from the iterator list before +// dying. +// +// Unfortunately, fixing this problem triggered by a std::string outliving its iterator +// introduced a problem triggered by an iterator outliving its container (of any type). +// When the long-lived iterator dies, it attempts to remove itself from its dead parent's +// iterator list. +// +// The fix for the VC8 RTM bug VSWhidbey.583388 (yet another debug mode, iterator debugging +// disabled bug) introduced a separate regression, DevDiv Bugs.36183, which was fixed +// before the final version of VC8 SP1 was released. This last fix is the interesting one. +// Now, the DLL (with iterator debugging ENABLED) is smart. In std::string::substr(), it +// detects that the original string, living in user code, has iterator debugging disabled. +// Accordingly, it disables iterator debugging on the temporary std::string it returns. +// (std::string::substr() is the only method that returns a temporary std::string like this.) +// Now, calling std::string::end() on the temporary doesn't register any iterators in any +// iterator lists. +// +// As the fix for DevDiv Bugs.36183 thoroughly solves the problem that the broken fix +// for VSWhidbey.579198 attempted to solve, we should remove the broken fix. This restores +// correctness to all known cases, and also increases efficiency (as iterator destructors +// in debug mode with iterator debugging disabled now perform no extra work). + +#include +#include +#include +#include + +using namespace std; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +#pragma warning(push) +#pragma warning(disable : 4582) // 'uninit_vector::storage': constructor is not implicitly called +#pragma warning(disable : 4583) // 'uninit_vector::storage': destructor is not implicitly called +union uninit_vector { + unsigned char bytes[sizeof(vector)]; + vector storage; + + constexpr uninit_vector() : bytes{} {} + uninit_vector(const uninit_vector&) = delete; + uninit_vector& operator=(const uninit_vector&) = delete; + ~uninit_vector() {} +}; +#pragma warning(pop) + +int main() { + puts("Beginning of test for DevDiv Bugs.52961 ..."); + + { + uninit_vector storage; + + puts("Constructing vector."); + + vector* const p = new (&storage.storage) vector; + + _Analysis_assume_(p); + + puts("Vector constructed. Pushing back values."); + + p->push_back(20); + p->push_back(30); + + puts("Values pushed back. Constructing iterator."); + + const vector::const_iterator i = p->begin(); + + puts("Iterator constructed. Using iterator."); + + assert(i[0] == 20); + assert(i[1] == 30); + + puts("Iterator use successful. Destroying container."); + + p->~vector(); + + puts("Container destroyed. Scribbling over memory."); + + memset(&storage.bytes, 0xC4, sizeof(storage.bytes)); + + puts("Memory scribbled. Destroying iterator (this should not crash)."); + } + + puts("Iterator destroyed successfully."); +} diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl b/tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl new file mode 100644 index 00000000000..74863cccb12 --- /dev/null +++ b/tests/std/tests/Dev09_056375_locale_cleanup/custombuild.pl @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +use Run; + +sub CustomBuildHook() +{ + my $cwd = Run::GetCWDName(); + Run::ExecuteCL("TestDll.cpp /FeTestDll.DLL /link /DLL"); + Run::ExecuteCL("Test.cpp /Fe$cwd.exe"); +} +1 diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/env.lst b/tests/std/tests/Dev09_056375_locale_cleanup/env.lst new file mode 100644 index 00000000000..7979e670487 --- /dev/null +++ b/tests/std/tests/Dev09_056375_locale_cleanup/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_winsdk_matrix.lst diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp b/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp new file mode 100644 index 00000000000..160041f7466 --- /dev/null +++ b/tests/std/tests/Dev09_056375_locale_cleanup/test.cpp @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include + +using namespace std; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +void test_dll() { + puts("Calling dll"); +#ifdef _M_CEE + using namespace System; + using namespace System::Reflection; + { + AppDomain ^ ad = AppDomain::CreateDomain("NewDomain"); + Assembly ^ as = ad->Load("testdll"); + as->GetType("Test")->GetMethod("DllTest")->Invoke(nullptr, nullptr); + AppDomain::Unload(ad); + } +#else + HMODULE hLibrary = LoadLibraryExW(L"testdll.dll", nullptr, 0); + assert(hLibrary != nullptr); + typedef void (*TheFuncProc)(); + TheFuncProc pFunc = (TheFuncProc) GetProcAddress(hLibrary, "DllTest"); + assert(pFunc != nullptr); + pFunc(); + FreeLibrary(hLibrary); +#endif +} + +void test_exe_part1() { + assert(isspace(' ', locale())); + assert(isspace(L' ', locale())); + assert(!isspace('Z', locale())); + assert(!isspace(L'Z', locale())); +} + +void test_exe_part2() { + assert(isspace(' ', locale())); + assert(isspace(L' ', locale())); + assert(!isspace('Z', locale())); + assert(!isspace(L'Z', locale())); +} + +int main() { +#ifdef _M_CEE + using namespace System; +#endif + test_exe_part1(); + test_dll(); + test_exe_part2(); +} diff --git a/tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp b/tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp new file mode 100644 index 00000000000..80b34748a72 --- /dev/null +++ b/tests/std/tests/Dev09_056375_locale_cleanup/testdll.cpp @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +using namespace std; + +// Tests for DLL +#ifdef _M_CEE +public +ref struct Test { + static +#else +extern "C" { +_declspec(dllexport) +#endif + + void + DllTest() { + assert(isspace(' ', locale())); + assert(isspace(L' ', locale())); + assert(!isspace('Z', locale())); + assert(!isspace(L'Z', locale())); + } +}; diff --git a/tests/std/tests/Dev09_098637_stl_function_typeids/env.lst b/tests/std/tests/Dev09_098637_stl_function_typeids/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_098637_stl_function_typeids/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_098637_stl_function_typeids/test.cpp b/tests/std/tests/Dev09_098637_stl_function_typeids/test.cpp new file mode 100644 index 00000000000..b2a11425779 --- /dev/null +++ b/tests/std/tests/Dev09_098637_stl_function_typeids/test.cpp @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +using namespace std; + +int main() { + ostringstream oss; + + ostream& r = (oss << 9 * 9 * 9 + 10 * 10 * 10); + + assert(oss.str() == "1729"); + + assert(typeid(r) == typeid(ostringstream)); + assert(typeid(r) != typeid(istringstream)); + assert(typeid(r) != typeid(stringstream)); + assert(typeid(r) != typeid(ostream)); +} diff --git a/tests/std/tests/Dev09_119637_throwing_string_with_hid0/env.lst b/tests/std/tests/Dev09_119637_throwing_string_with_hid0/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_119637_throwing_string_with_hid0/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_119637_throwing_string_with_hid0/test.cpp b/tests/std/tests/Dev09_119637_throwing_string_with_hid0/test.cpp new file mode 100644 index 00000000000..c11cb52bd5b --- /dev/null +++ b/tests/std/tests/Dev09_119637_throwing_string_with_hid0/test.cpp @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include + +int main() { + try { + throw std::string("meow"); + } catch (...) { + } +} diff --git a/tests/std/tests/Dev09_119644_compiler_option_gz/env.lst b/tests/std/tests/Dev09_119644_compiler_option_gz/env.lst new file mode 100644 index 00000000000..b3781107f47 --- /dev/null +++ b/tests/std/tests/Dev09_119644_compiler_option_gz/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\callconv_matrix.lst diff --git a/tests/std/tests/Dev09_119644_compiler_option_gz/test.cpp b/tests/std/tests/Dev09_119644_compiler_option_gz/test.cpp new file mode 100644 index 00000000000..1f5964b0740 --- /dev/null +++ b/tests/std/tests/Dev09_119644_compiler_option_gz/test.cpp @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include <__msvc_all_public_headers.hpp> + +#ifdef _M_CEE_PURE +int main() { +#else +int __cdecl main() { +#endif + // Test Dev10#465793 "iostreams: is incompatible with /Gr and /Gz". + std::locale loc("english_US"); +} diff --git a/tests/std/tests/Dev09_126254_persistent_aux_allocators/env.lst b/tests/std/tests/Dev09_126254_persistent_aux_allocators/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_126254_persistent_aux_allocators/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_126254_persistent_aux_allocators/test.cpp b/tests/std/tests/Dev09_126254_persistent_aux_allocators/test.cpp new file mode 100644 index 00000000000..94d4d1dd17f --- /dev/null +++ b/tests/std/tests/Dev09_126254_persistent_aux_allocators/test.cpp @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +map g_map; + +size_t g_next_id = 0; + +template +class MyAllocator { +public: + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + template + struct rebind { + typedef MyAllocator other; + }; + + T* address(T& r) const { + return &r; + }; + + const T* address(const T& s) const { + return &s; + } + + T* allocate(size_t n) const { + ++g_map[m_id]; + + return static_cast(::operator new(n * sizeof(T))); + } + + template + T* allocate(size_t n, const U*) const { + return allocate(n); + } + + void deallocate(T* p, size_t) const { + --g_map[m_id]; + + ::operator delete(p); + } + + size_t max_size() const { + return 1000000; + } + + bool operator==(const MyAllocator& other) const { + return m_id == other.m_id; + } + + bool operator!=(const MyAllocator& other) const { + return m_id != other.m_id; + } + + MyAllocator() : m_id(g_next_id++) {} + MyAllocator(const MyAllocator& right) : m_id(right.m_id) {} + template + MyAllocator(const MyAllocator& right) : m_id(right.m_id) {} + + void construct(T* p, const T& t) const { + new (static_cast(p)) T(t); + } + + void destroy(T* p) const { + p->~T(); + } + + MyAllocator& operator=(const MyAllocator&); + + size_t m_id; +}; + +void dump_map() { + for (auto&& entry : g_map) { + printf("ID: %zu | allocate - deallocate: %i\n", entry.first, entry.second); + } +} + +int main() { + { + vector> v; + deque> d; + list> l; + forward_list> fl; + set, MyAllocator> s; + multiset, MyAllocator> ms; + map, MyAllocator>> m; + multimap, MyAllocator>> mm; + unordered_set, equal_to, MyAllocator> us; + unordered_multiset, equal_to, MyAllocator> ums; + unordered_map, equal_to, MyAllocator>> um; + unordered_multimap, equal_to, MyAllocator>> umm; + } + + for (auto&& entry : g_map) { + if (entry.second != 0) { + dump_map(); + abort(); + } + } +} diff --git a/tests/std/tests/Dev09_130060_unique_copy/env.lst b/tests/std/tests/Dev09_130060_unique_copy/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_130060_unique_copy/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_130060_unique_copy/test.cpp b/tests/std/tests/Dev09_130060_unique_copy/test.cpp new file mode 100644 index 00000000000..416e6c5a21f --- /dev/null +++ b/tests/std/tests/Dev09_130060_unique_copy/test.cpp @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +using namespace std; + +string join(const vector& source) { + string result; + if (!source.empty()) { + result.append(to_string(source[0])); + for (size_t idx = 1; idx < source.size(); ++idx) { + result.push_back(' '); + result.append(to_string(source[idx])); + } + } + + return result; +} + +void test_case_forward_source(const vector& source, const vector& expected) { + vector actual; + unique_copy(source.cbegin(), source.cend(), back_inserter(actual)); + assert(actual == expected); +} + +void test_case_forward_dest_same_t(const vector& source, const vector& expected) { + stringstream ss(join(source)); + vector actual(expected.size(), 0); + assert(unique_copy(istream_iterator(ss), istream_iterator(), actual.begin()) == actual.end()); + + assert(actual == expected); +} + +void test_case_forward_dest_different_t(const vector& source, const vector& expected) { + stringstream ss(join(source)); + vector actual(expected.size(), 0); + assert(unique_copy(istream_iterator(ss), istream_iterator(), actual.begin()) == actual.end()); + + assert(equal(actual.cbegin(), actual.cend(), expected.cbegin(), expected.cend())); +} + +void test_case_no_forwards(const vector& source, const vector& expected) { + stringstream ss(join(source)); + vector actual; + unique_copy(istream_iterator(ss), istream_iterator(), back_inserter(actual)); + + assert(actual == expected); +} + +void test_case(const vector& source, const vector& expected) { + test_case_forward_source(source, expected); + test_case_forward_dest_same_t(source, expected); + test_case_forward_dest_different_t(source, expected); + test_case_no_forwards(source, expected); +} + +int main() { + test_case({}, {}); + test_case({1}, {1}); + test_case({1, 1}, {1}); + test_case({1, 2, 2, 3, 4, 4, 5}, {1, 2, 3, 4, 5}); +} diff --git a/tests/std/tests/Dev09_152755_tr1_nested_bind/env.lst b/tests/std/tests/Dev09_152755_tr1_nested_bind/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_152755_tr1_nested_bind/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_152755_tr1_nested_bind/test.cpp b/tests/std/tests/Dev09_152755_tr1_nested_bind/test.cpp new file mode 100644 index 00000000000..f8e9613c174 --- /dev/null +++ b/tests/std/tests/Dev09_152755_tr1_nested_bind/test.cpp @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include + +using namespace std; +using namespace std::placeholders; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +class point { +public: + point(double x, double y) : m_x(x), m_y(y) {} + + double mag() const { + return sqrt(m_x * m_x + m_y * m_y); + } + +private: + double m_x; + double m_y; +}; + +int main() { + vector v; + + v.push_back(point(3, 4)); + v.push_back(point(5, 12)); + v.push_back(point(8, 15)); + + assert(count_if(v.begin(), v.end(), bind(greater(), bind(&point::mag, _1), 10)) == 2); +} diff --git a/tests/std/tests/Dev09_153419_tr1_allocators/env.lst b/tests/std/tests/Dev09_153419_tr1_allocators/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_153419_tr1_allocators/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_153419_tr1_allocators/test.cpp b/tests/std/tests/Dev09_153419_tr1_allocators/test.cpp new file mode 100644 index 00000000000..e82ad3bc489 --- /dev/null +++ b/tests/std/tests/Dev09_153419_tr1_allocators/test.cpp @@ -0,0 +1,453 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +// This defines a malloc()-based allocator named Mallocator, instrumented +// to count the number of calls to malloc() and free(). It also replaces +// the global allocation and deallocation functions, instrumenting them to +// count the number of calls to new and delete. +// +// Then it exercises shared_ptr and function's new allocator-taking +// interfaces, making sure that the Mallocator is actually used. +// +// Big is 7 * 64 bits to disable the Small Functor Optimization. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +#pragma warning(disable : 28251) // Inconsistent annotation for 'new': this instance has no annotations. + +int g_mallocs = 0; +int g_frees = 0; +int g_constructs = 0; +int g_destroys = 0; + +template +struct Mallocator { + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + template + struct rebind { + typedef Mallocator other; + }; + + T* address(T& t) const { + return &t; + } + + const T* address(const T& t) const { + return &t; + } + + T* allocate(const size_t n) const { + ++g_mallocs; + + if (n == 0) { + return nullptr; + } + + return static_cast(malloc(n * sizeof(T))); + } + + template + T* allocate(const size_t n, const U*) const { + return allocate(n); + } + + void deallocate(T* const p, size_t) const { + ++g_frees; + + free(p); + } + + size_t max_size() const { + return 1000000; + } + + bool operator==(const Mallocator&) const { + return true; + } + + bool operator!=(const Mallocator&) const { + return false; + } + + Mallocator() {} + + template + Mallocator(const Mallocator&) {} + + template + void construct(T* const p, const U&... u) const { + ++g_constructs; + + new (static_cast(p)) T(u...); + } + + void destroy(T* const p) const { + ++g_destroys; + + p->~T(); + } +}; + +int g_news = 0; +int g_deletes = 0; + +void* operator new(size_t size) { + void* const p = ::operator new(size, nothrow); + + if (p) { + return p; + } else { + throw bad_alloc(); + } +} + +void* operator new(size_t size, const nothrow_t&) noexcept { + ++g_news; + + void* const result = malloc(size == 0 ? 1 : size); + if (result) { + memset(result, 0xDD, size); + } + + return result; +} + +void operator delete(void* ptr) noexcept { + ::operator delete(ptr, nothrow); +} + +void operator delete(void* ptr, const nothrow_t&) noexcept { + if (ptr) { + ++g_deletes; + + free(ptr); + } +} + +void* operator new[](size_t size) { + return ::operator new(size); +} + +void* operator new[](size_t size, const nothrow_t&) noexcept { + return ::operator new(size, nothrow); +} + +void operator delete[](void* ptr) noexcept { + ::operator delete(ptr); +} + +void operator delete[](void* ptr, const nothrow_t&) noexcept { + ::operator delete(ptr, nothrow); +} + +void custom_deleter(int* const p) { + delete p; +} + +void test(const int mallocs, const int frees, const int news, const int deletes, const int line) { + if (g_mallocs != mallocs) { + printf("FAIL: On line %d, g_mallocs is %d but should be %d.\n", line, g_mallocs, mallocs); + abort(); + } + + if (g_frees != frees) { + printf("FAIL: On line %d, g_frees is %d but should be %d.\n", line, g_frees, frees); + abort(); + } + + if (g_news != news) { + printf("FAIL: On line %d, g_news is %d but should be %d.\n", line, g_news, news); + abort(); + } + + if (g_deletes != deletes) { + printf("FAIL: On line %d, g_deletes is %d but should be %d.\n", line, g_deletes, deletes); + abort(); + } +} + +void test_constructors(const int constructs, const int destroys, const int line) { + if (g_constructs != constructs) { + printf("FAIL: On line %d, g_constructs is %d but should be %d.\n", line, g_constructs, constructs); + abort(); + } + + if (g_destroys != destroys) { + printf("FAIL: On line %d, g_destroys is %d but should be %d.\n", line, g_destroys, destroys); + abort(); + } +} + +#define TEST(A, B, C, D) test(A, B, C, D, __LINE__) +#define TEST_CONSTRUCTORS(A, B) test_constructors(A, B, __LINE__) + +void reset_counters() { + g_mallocs = g_frees = g_constructs = g_destroys = g_news = g_deletes = 0; + TEST(0, 0, 0, 0); + TEST_CONSTRUCTORS(0, 0); +} + +typedef unsigned long long ull_t; + +struct Big { + Big(const ull_t a, const ull_t b, const ull_t c, const ull_t d) + : m_a(a), m_b(b), m_c(c), m_d(d), m_e(0), m_f(0), m_g(0) {} + + ull_t operator()() const { + return m_a * m_b + m_c * m_d; + } + + ull_t m_a; + ull_t m_b; + ull_t m_c; + ull_t m_d; + ull_t m_e; + ull_t m_f; + ull_t m_g; +}; + +ull_t func() { + return 0x12345678DEADBEEFULL; +} + +int main() { + // Ignore any allocations that were performed during CRT startup. + reset_counters(); + + { + int* const raw = new int(47); + + TEST(0, 0, 1, 0); + + shared_ptr sp(raw, custom_deleter, Mallocator()); + + TEST(1, 0, 1, 0); + + weak_ptr wp(sp); + + TEST(1, 0, 1, 0); + + sp.reset(); + + TEST(1, 0, 1, 1); + + wp.reset(); + + TEST(1, 1, 1, 1); + } + + reset_counters(); + + { + int* const raw = new int(47); + + TEST(0, 0, 1, 0); + + shared_ptr sp; + + TEST(0, 0, 1, 0); + + sp.reset(raw, custom_deleter, Mallocator()); + + TEST(1, 0, 1, 0); + + weak_ptr wp(sp); + + TEST(1, 0, 1, 0); + + sp.reset(); + + TEST(1, 0, 1, 1); + + wp.reset(); + + TEST(1, 1, 1, 1); + } + + reset_counters(); + + { + shared_ptr sp; + + TEST(0, 0, 0, 0); + + sp = allocate_shared(Mallocator(), 1729); + + TEST(1, 0, 0, 0); + + weak_ptr wp(sp); + + TEST(1, 0, 0, 0); + + sp.reset(); + + TEST(1, 0, 0, 0); + + wp.reset(); + + TEST(1, 1, 0, 0); + } + + reset_counters(); + +#if _HAS_FUNCTION_ALLOCATOR_SUPPORT + { + function f(allocator_arg, Mallocator(), Big(10, 20, 30, 40)); + + TEST(1, 0, 0, 0); + + f = nullptr; + + TEST(1, 1, 0, 0); + } + + reset_counters(); +#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT + + { + function f = func; + + TEST(0, 0, 0, 0); + + f = nullptr; + + TEST(0, 0, 0, 0); + + f = func; + + TEST(0, 0, 0, 0); + + f = nullptr; + + TEST(0, 0, 0, 0); + } + + reset_counters(); + +#if _HAS_FUNCTION_ALLOCATOR_SUPPORT + { + function f(allocator_arg, Mallocator(), func); + + TEST(0, 0, 0, 0); + + f = nullptr; + + TEST(0, 0, 0, 0); + } + + reset_counters(); +#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT + + { + Big b(10, 20, 30, 40); + + function f = ref(b); + + TEST(0, 0, 0, 0); + + f = nullptr; + + TEST(0, 0, 0, 0); + + f = ref(b); + + TEST(0, 0, 0, 0); + + f = nullptr; + + TEST(0, 0, 0, 0); + } + + reset_counters(); + +#if _HAS_FUNCTION_ALLOCATOR_SUPPORT + { + Big b(10, 20, 30, 40); + + function f(allocator_arg, Mallocator(), ref(b)); + + TEST(0, 0, 0, 0); + + f = nullptr; + + TEST(0, 0, 0, 0); + } + + reset_counters(); +#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT + + { + // Test Dev10#531321 "function: tr1::function memory leak". + + Big b(10, 20, 30, 40); + function f; + + TEST(0, 0, 0, 0); + + f = b; + TEST(0, 0, 1, 0); + f = b; + TEST(0, 0, 2, 1); + f = nullptr; + TEST(0, 0, 2, 2); + } + + reset_counters(); + + { + // Test (indirectly) _Uninitialized_fill_n with non-default allocator + vector> vec(3, static_cast(-2)); + TEST_CONSTRUCTORS(3, 0); + for (char c : vec) { + assert(c == static_cast(-2)); + } + + // Test (indirectly) _Uninitialized_copy with non-default allocator + vector> vecCopy(vec); + TEST_CONSTRUCTORS(6, 0); + + // Test (indirectly) _Uninitialized_move with non-default allocator + vec.reserve(100); + TEST_CONSTRUCTORS(9, 3); + + // Test (indirectly) _Destroy_range with non-default allocator + vec.clear(); + TEST_CONSTRUCTORS(9, 6); + } + + reset_counters(); + + { + // Test (indirectly) _Uninitialized_default_fill_n with non-default allocator + vector> vec(3); + TEST_CONSTRUCTORS(3, 0); + if (any_of(vec.begin(), vec.end(), [](char x) { return x != '\0'; })) { + puts("vector didn't clear its contents"); + abort(); + } + + vec.clear(); + + TEST_CONSTRUCTORS(3, 3); + } + + reset_counters(); +} diff --git a/tests/std/tests/Dev09_154033_tr1_predicate_search_n/env.lst b/tests/std/tests/Dev09_154033_tr1_predicate_search_n/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_154033_tr1_predicate_search_n/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_154033_tr1_predicate_search_n/test.cpp b/tests/std/tests/Dev09_154033_tr1_predicate_search_n/test.cpp new file mode 100644 index 00000000000..6b726c80d3b --- /dev/null +++ b/tests/std/tests/Dev09_154033_tr1_predicate_search_n/test.cpp @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +struct X { + explicit X(const int n) : m_n(n) {} + + int m_n; +}; + +bool parity(const X& a, const X& b) { + return a.m_n % 2 == b.m_n % 2; +} + +int main() { + const int arr[] = {1, 2, 3, 4, 6, 7, 9, 10, 12, 14, 15, 17, 19, 20}; + + std::vector v; + + for (const auto& e : arr) { + v.emplace_back(e); + } + + const X x(99); + + const std::vector::const_iterator p = std::search_n(v.begin(), v.end(), 3, x, parity); + + assert(p != v.end() && p->m_n == 15); +} diff --git a/tests/std/tests/Dev09_155328_tr1_vector_of_set/env.lst b/tests/std/tests/Dev09_155328_tr1_vector_of_set/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_155328_tr1_vector_of_set/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_155328_tr1_vector_of_set/test.cpp b/tests/std/tests/Dev09_155328_tr1_vector_of_set/test.cpp new file mode 100644 index 00000000000..1c45dccac4c --- /dev/null +++ b/tests/std/tests/Dev09_155328_tr1_vector_of_set/test.cpp @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +using namespace std; + +int main() { + vector> v; + + v.push_back(set()); + + v[0].insert(55); + + v.push_back(v[0]); + + assert(v[1].size() == 1); +} diff --git a/tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/env.lst b/tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/test.cpp b/tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/test.cpp new file mode 100644 index 00000000000..15401c46f56 --- /dev/null +++ b/tests/std/tests/Dev09_158181_tr1_unordered_meow_swap/test.cpp @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +void assert_is_pow2(const size_t value) { + assert(value != 0 && ((value & (value - 1)) == 0)); +} + +void assert_close(const float f, const float g) { + assert(abs(f - g) < 0.01f); +} + +template +void assert_throws(Fx fn) noexcept { + try { + fn(); + abort(); + } catch (const X&) { + } +} + +// Test DDB#158181. unordered_set.swap() was O(N), throwing, and invalidating iterators, which was bad. +void test_ddb_158181() { + unordered_set x; + x.insert(11); + x.insert(21); + x.insert(31); + + unordered_set y; + y.insert(42); + y.insert(52); + y.insert(62); + + const auto a = x.cbegin(); + const auto b = y.cbegin(); + + const int a1 = *a; + const int b1 = *b; + + x.swap(y); + + STATIC_ASSERT(noexcept(x.swap(y))); + + const int a2 = *a; + const int b2 = *b; + + assert(a1 == a2 && b1 == b2); +} + +// Also test swapping/assigning max_load_factor(), broken in VS 2015 RTM. +void test_max_load_factor() { + unordered_set x{10, 11, 12, 13, 14}; + unordered_set y{20, 21, 22, 23, 24}; + unordered_set z{30, 31, 32, 33, 34}; + + x.max_load_factor(1.1f); + y.max_load_factor(2.2f); + z.max_load_factor(3.3f); + + assert_close(x.max_load_factor(), 1.1f); + assert_close(y.max_load_factor(), 2.2f); + assert_close(z.max_load_factor(), 3.3f); + + x.swap(y); + + assert_close(x.max_load_factor(), 2.2f); + assert_close(y.max_load_factor(), 1.1f); + + x = y; + + assert_close(x.max_load_factor(), 1.1f); + assert_close(y.max_load_factor(), 1.1f); + + x = move(z); + + assert_close(x.max_load_factor(), 3.3f); +} + +void test_floor_log2() { + assert(_Floor_of_log_2(0) == 0); + size_t expected = 0; + for (size_t test = 2; test != 0; test <<= 1) { + assert(_Floor_of_log_2(test - 1) == expected); + ++expected; + assert(_Floor_of_log_2(test) == expected); + assert(_Floor_of_log_2(test + 1) == expected); + } +} + +void test_LWG_2156() { + unordered_set x; + + x.max_load_factor(5.0f); + for (int i = 0; i < 100; ++i) { + x.emplace(i); + assert_is_pow2(x.bucket_count()); // MSVC++ specific invariant + } + + const auto afterEmplaceBuckets = x.bucket_count(); + x.max_load_factor(1.0f); // break usual container attempt to maintain bucket_count() >= size() / max_load_factor() + assert(!(x.load_factor() <= x.max_load_factor())); // assert invariant broken + assert(afterEmplaceBuckets == x.bucket_count()); // max_load_factor must not rehash the container + x.rehash(0); // container will have to choose more buckets to restore bucket_count() >= size() / max_load_factor() + const auto afterRehashBuckets = x.bucket_count(); + assert_is_pow2(afterRehashBuckets); + assert(afterRehashBuckets >= x.size()); // check postcondition directly + assert(x.load_factor() <= x.max_load_factor()); + x.erase(0); // keeping the same number of elements must not cause a rehash + x.emplace(0); + assert(x.bucket_count() == afterRehashBuckets); + + assert_throws([&] { x.rehash(SIZE_MAX); }); + assert_throws([&] { x.rehash(SIZE_MAX / 2); }); + +#ifndef _WIN64 + // make it so rehash can't meet its postcondition, even when not asking for more buckets + // skip on 64 bit because creating reasonable container sizes to trigger this problem there + // consumes too much RAM. + x.max_load_factor(FLT_EPSILON); + assert_throws([&] { x.rehash(0); }); +#endif // !_WIN64 +} + +void test_bad_rehash_size() { + unordered_set x; + x.max_load_factor(1.0f); + const auto initialBuckets = x.bucket_count(); + for (size_t i = 0; i < initialBuckets; ++i) { + x.emplace(i); + } + + assert(x.bucket_count() == initialBuckets); // the above shouldn't have rehashed + assert(x.load_factor() <= x.max_load_factor()); + x.max_load_factor(1.0f / 64.0f); // force 64 buckets per element, so that multiply by 8 on emplace insufficient + x.emplace(initialBuckets); // trigger rehash + assert(x.bucket_count() > initialBuckets); + assert(x.load_factor() <= x.max_load_factor()); +} + +int main() { + test_ddb_158181(); + test_max_load_factor(); + test_floor_log2(); + test_LWG_2156(); + test_bad_rehash_size(); +} diff --git a/tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/env.lst b/tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/env.lst new file mode 100644 index 00000000000..b3781107f47 --- /dev/null +++ b/tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\callconv_matrix.lst diff --git a/tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/test.cpp b/tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/test.cpp new file mode 100644 index 00000000000..c303105ce08 --- /dev/null +++ b/tests/std/tests/Dev09_158457_tr1_mem_fn_calling_conventions/test.cpp @@ -0,0 +1,350 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +using namespace std; + +#if defined(_M_IX86) && _M_IX86_FP < 2 +#error On x86, this test assumes _M_IX86_FP >= 2 +#endif + +struct Cat { + int a() { + return 2000000; + } + +#if !defined(_M_CEE_PURE) + int __thiscall b() { + return 200000; + } +#else + int b() { + return 100000; + } +#endif + +#if defined(_M_IX86) && !defined(_M_CEE_PURE) + int __cdecl c() { + return 20000; + } + int __stdcall d() { + return 2000; + } +#else + int c() { + return 10000; + } + int d() { + return 1000; + } +#endif + +#if defined(_M_IX86) && !defined(_M_CEE) + int __fastcall e() { + return 200; + } +#else + int e() { + return 100; + } +#endif + +#if defined(_M_CEE) + int __clrcall f() { + return 20; + } +#else + int f() { + return 10; + } +#endif + +#if (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE) + int __vectorcall g() { + return 2; + } +#else + int g() { + return 1; + } +#endif +}; + +int u(int i) { + return -400000 * i; +} + +#if defined(_M_IX86) && !defined(_M_CEE_PURE) +int __cdecl v(int i) { + return -40000 * i; +} +int __stdcall w(int i) { + return -4000 * i; +} +#else +int v(int i) { + return -30000 * i; +} +int w(int i) { + return -3000 * i; +} +#endif + +#if defined(_M_IX86) && !defined(_M_CEE) +int __fastcall x(int i) { + return -400 * i; +} +#else +int x(int i) { + return -300 * i; +} +#endif + +#if defined(_M_CEE) +int __clrcall y(int i) { + return -40 * i; +} +#else +int y(int i) { + return -30 * i; +} +#endif + +#if (defined(_M_IX86) || defined(_M_X64)) && !defined(_M_CEE) +int __vectorcall z(int i) { + return -4 * i; +} +#else +int z(int i) { + return -3 * i; +} +#endif + +#if defined(_M_IX86) +#if !defined(_M_CEE) +const int member_correct = 2222212; // x86 native +const int free_correct = 444434; // x86 native +#elif !defined(_M_CEE_PURE) +const int member_correct = 2222121; // x86 ijw +const int free_correct = 444343; // x86 ijw +#else +const int member_correct = 2111121; // x86 pure +const int free_correct = 433343; // x86 pure +#endif +#elif defined(_M_X64) +#if !defined(_M_CEE) +const int member_correct = 2211112; // x64 native +const int free_correct = 433334; // x64 native +#elif !defined(_M_CEE_PURE) +const int member_correct = 2211121; // x64 ijw +const int free_correct = 433343; // x64 ijw +#else +const int member_correct = 2111121; // x64 pure +const int free_correct = 433343; // x64 pure +#endif +#else +#if !defined(_M_CEE) +const int member_correct = 2211111; // arm/arm64 native +const int free_correct = 433333; // arm/arm64 native +#elif !defined(_M_CEE_PURE) +const int member_correct = 2211121; // arm/arm64 ijw +const int free_correct = 433343; // arm/arm64 ijw +#else +const int member_correct = 2111121; // arm/arm64 pure +const int free_correct = 433343; // arm/arm64 pure +#endif +#endif + +STATIC_ASSERT(is_member_function_pointer_v); +STATIC_ASSERT(is_member_function_pointer_v); +STATIC_ASSERT(is_member_function_pointer_v); +STATIC_ASSERT(is_member_function_pointer_v); +STATIC_ASSERT(is_member_function_pointer_v); +STATIC_ASSERT(is_member_function_pointer_v); +STATIC_ASSERT(is_member_function_pointer_v); + +STATIC_ASSERT(is_function_v); +STATIC_ASSERT(is_function_v); +STATIC_ASSERT(is_function_v); +STATIC_ASSERT(is_function_v); +STATIC_ASSERT(is_function_v); +STATIC_ASSERT(is_function_v); + + +// use_mem_fn() works around the fact that we can't always decompose and recompose PMF types. Consider +// x86 /Gd (the default), where non-members default to __cdecl and members default to __thiscall. When +// a member has been marked as __cdecl, like &Cat::c, we can't give it to mem_fn(). We're required to +// provide the signature mem_fn(R T::*). Template argument deduction decomposes the PMF type into an +// ordinary function type, then substitution recomposes the PMF type. This works for default calling +// conventions (__thiscall PMFs become __cdecl non-members and back). It also works for fancy calling +// conventions (e.g. __stdcall PMFs become __stdcall non-members and back). However, it fails when the +// PMF's calling convention is what non-members have by default. A __cdecl PMF becomes a __cdecl +// non-member, then recomposition produces a __thiscall PMF. use_mem_fn() allows us to ignore this +// problem. When recomposition succeeds (as it usually does), both use_mem_fn(R Cat::*) and +// use_mem_fn(PMF) are viable, and use_mem_fn(R Cat::*) is chosen because it's more specialized. When +// recomposition fails, use_mem_fn(R Cat::*) is non-viable, so use_mem_fn(PMF) is chosen. (In Standard +// code, it's entirely possible for template argument deduction to succeed, but for the overload to be +// non-viable.) + +template +int use_mem_fn(R Cat::*pmf) { + Cat cat; + return mem_fn(pmf)(cat); +} + +template +int use_mem_fn(PMF pmf) { + Cat cat; + return (cat.*pmf)(); +} + +#ifdef _M_CEE_PURE +int main() { +#else +int __cdecl main() { +#endif + Cat cat; + int n = 0; + + n = 0; + n += use_mem_fn(&Cat::a); + n += use_mem_fn(&Cat::b); + n += use_mem_fn(&Cat::c); + n += use_mem_fn(&Cat::d); + n += use_mem_fn(&Cat::e); + n += use_mem_fn(&Cat::f); + n += use_mem_fn(&Cat::g); + assert(n == member_correct); + + n = 0; + n += bind(&Cat::a, cat)(); + n += bind(&Cat::b, cat)(); + n += bind(&Cat::c, cat)(); + n += bind(&Cat::d, cat)(); + n += bind(&Cat::e, cat)(); + n += bind(&Cat::f, cat)(); + n += bind(&Cat::g, cat)(); + assert(n == member_correct); + + n = 0; + n += bind(u, -1)(); + n += bind(v, -1)(); + n += bind(w, -1)(); + n += bind(x, -1)(); + n += bind(y, -1)(); + n += bind(z, -1)(); + assert(n == free_correct); + + n = 0; + n += bind(&u, -1)(); + n += bind(&v, -1)(); + n += bind(&w, -1)(); + n += bind(&x, -1)(); + n += bind(&y, -1)(); + n += bind(&z, -1)(); + assert(n == free_correct); + + n = 0; + n += function(&Cat::a)(cat); + n += function(&Cat::b)(cat); + n += function(&Cat::c)(cat); + n += function(&Cat::d)(cat); + n += function(&Cat::e)(cat); + n += function(&Cat::f)(cat); + n += function(&Cat::g)(cat); + assert(n == member_correct); + + n = 0; + n += function(u)(-1); + n += function(v)(-1); + n += function(w)(-1); + n += function(x)(-1); + n += function(y)(-1); + n += function(z)(-1); + assert(n == free_correct); + + n = 0; + n += function(&u)(-1); + n += function(&v)(-1); + n += function(&w)(-1); + n += function(&x)(-1); + n += function(&y)(-1); + n += function(&z)(-1); + assert(n == free_correct); + + auto pmf_a = &Cat::a; + auto pmf_b = &Cat::b; + auto pmf_c = &Cat::c; + auto pmf_d = &Cat::d; + auto pmf_e = &Cat::e; + auto pmf_f = &Cat::f; + auto pmf_g = &Cat::g; + + n = 0; + n += ref(pmf_a)(cat); + n += ref(pmf_b)(cat); + n += ref(pmf_c)(cat); + n += ref(pmf_d)(cat); + n += ref(pmf_e)(cat); + n += ref(pmf_f)(cat); + n += ref(pmf_g)(cat); + assert(n == member_correct); + + n = 0; + n += cref(pmf_a)(cat); + n += cref(pmf_b)(cat); + n += cref(pmf_c)(cat); + n += cref(pmf_d)(cat); + n += cref(pmf_e)(cat); + n += cref(pmf_f)(cat); + n += cref(pmf_g)(cat); + assert(n == member_correct); + + n = 0; + n += ref(u)(-1); + n += ref(v)(-1); + n += ref(w)(-1); + n += ref(x)(-1); + n += ref(y)(-1); + n += ref(z)(-1); + assert(n == free_correct); + + n = 0; + n += cref(u)(-1); + n += cref(v)(-1); + n += cref(w)(-1); + n += cref(x)(-1); + n += cref(y)(-1); + n += cref(z)(-1); + assert(n == free_correct); + + auto pf_u = &u; + auto pf_v = &v; + auto pf_w = &w; + auto pf_x = &x; + auto pf_y = &y; + auto pf_z = &z; + + n = 0; + n += ref(pf_u)(-1); + n += ref(pf_v)(-1); + n += ref(pf_w)(-1); + n += ref(pf_x)(-1); + n += ref(pf_y)(-1); + n += ref(pf_z)(-1); + assert(n == free_correct); + + n = 0; + n += cref(pf_u)(-1); + n += cref(pf_v)(-1); + n += cref(pf_w)(-1); + n += cref(pf_x)(-1); + n += cref(pf_y)(-1); + n += cref(pf_z)(-1); + assert(n == free_correct); +} diff --git a/tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/env.lst b/tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/test.cpp b/tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/test.cpp new file mode 100644 index 00000000000..7baefd4aec8 --- /dev/null +++ b/tests/std/tests/Dev09_161106_tr1_bind_templated_fxn_call_operator/test.cpp @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; +using namespace std::placeholders; + +struct Div { + template + T operator()(const T& left, const U& right) const { + return left / right; + } +}; + +int main() { + const Div div{}; + + const int a = 16; + const int b = 3; + const int i = bind(div, a, _1)(b); + + assert(i == 5); +} diff --git a/tests/std/tests/Dev09_165853_tr1_tuple_swap/env.lst b/tests/std/tests/Dev09_165853_tr1_tuple_swap/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_165853_tr1_tuple_swap/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_165853_tr1_tuple_swap/test.cpp b/tests/std/tests/Dev09_165853_tr1_tuple_swap/test.cpp new file mode 100644 index 00000000000..51f10300091 --- /dev/null +++ b/tests/std/tests/Dev09_165853_tr1_tuple_swap/test.cpp @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include + +int main() { + using tuple_t = std::tuple; + + const tuple_t one(1, "one"); + const tuple_t two(2, "two"); + + tuple_t x = one; + tuple_t y = two; + + assert(x == one && y == two); + + x.swap(y); + + assert(y == one && x == two); + + std::swap(x, y); + + assert(x == one && y == two); +} diff --git a/tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/env.lst b/tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/test.cpp b/tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/test.cpp new file mode 100644 index 00000000000..34d3f6ad7ef --- /dev/null +++ b/tests/std/tests/Dev09_171205_tr1_assign_pair_to_tuple/test.cpp @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +using namespace std; + +int main() { + int a = 0; + int b = 0; + + pair p(1, 2); + + tie(a, b) = p; + + assert(a == 1 && b == 2); + + const pair q(3, 4); + + tie(a, b) = q; + + assert(a == 3 && b == 4); +} diff --git a/tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/env.lst b/tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/test.cpp b/tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/test.cpp new file mode 100644 index 00000000000..31e85b3c163 --- /dev/null +++ b/tests/std/tests/Dev09_172497_tr1_mem_fn_const_correctness/test.cpp @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#define _HAS_DEPRECATED_ADAPTOR_TYPEDEFS 1 +#define _SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING + +#include +#include + +using namespace std; + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +struct Cat { + float meow() { + return 11.1f; + } + float meow_c() const { + return 11.1f; + } + float meow_v() volatile { + return 11.1f; + } + float meow_cv() const volatile { + return 11.1f; + } + + double purr(int) { + return 22.2; + } + double purr_c(int) const { + return 22.2; + } + double purr_v(int) volatile { + return 22.2; + } + double purr_cv(int) const volatile { + return 22.2; + } +}; + +// FDIS 20.8.10 [func.memfn]/2: "The simple call wrapper shall define two nested types named +// argument_type and result_type as synonyms for cv T* and Ret, respectively, when pm is a pointer to +// member function with cv-qualifier cv and taking no arguments, where Ret is pm's return type." +template +void test_unary(F) { + STATIC_ASSERT(is_same_v); + STATIC_ASSERT(is_same_v); +} + +// FDIS 20.8.10 [func.memfn]/3: "The simple call wrapper shall define three nested types named +// first_argument_type, second_argument_type, and result_type as synonyms for cv T*, T1, and Ret, +// respectively, when pm is a pointer to member function with cv-qualifier cv and taking one argument +// of type T1, where Ret is pm's return type." +template +void test_binary(F) { + STATIC_ASSERT(is_same_v); + STATIC_ASSERT(is_same_v); + STATIC_ASSERT(is_same_v); +} + +int main() { + test_unary(mem_fn(&Cat::meow)); + test_unary(mem_fn(&Cat::meow_c)); + test_unary(mem_fn(&Cat::meow_v)); + test_unary(mem_fn(&Cat::meow_cv)); + + test_binary(mem_fn(&Cat::purr)); + test_binary(mem_fn(&Cat::purr_c)); + test_binary(mem_fn(&Cat::purr_v)); + test_binary(mem_fn(&Cat::purr_cv)); +} diff --git a/tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/env.lst b/tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/test.cpp b/tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/test.cpp new file mode 100644 index 00000000000..02bbce83167 --- /dev/null +++ b/tests/std/tests/Dev09_172505_tr1_bind_reference_wrapper/test.cpp @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; + +struct Cat { + int m_n; + + void square() { + m_n *= m_n; + } +}; + +int main() { + Cat c = {4}; + + bind(&Cat::square, ref(c))(); + + assert(c.m_n == 16); +} diff --git a/tests/std/tests/Dev09_172666_tr1_tuple_odr/env.lst b/tests/std/tests/Dev09_172666_tr1_tuple_odr/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_172666_tr1_tuple_odr/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_172666_tr1_tuple_odr/one.cpp b/tests/std/tests/Dev09_172666_tr1_tuple_odr/one.cpp new file mode 100644 index 00000000000..05cd4dc827d --- /dev/null +++ b/tests/std/tests/Dev09_172666_tr1_tuple_odr/one.cpp @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include <__msvc_all_public_headers.hpp> +#include + +namespace fs = std::experimental::filesystem; + +int meow(); + +inline bool test_wchar_t_minus() { + // Test for DevDiv Bug#1004799: : /Zc:wchar_t- explodes. Calling file_size + // should cause the blow-up to occur if we are wchar_t incorrect. Test is disabled + // (i.e. always passes) if compiled with /clr:pure and /Zc:wchar_t-, as it triggers + // LNK2031: calling convention missing in metadata errors, which are irrelevant here. +#if defined(_M_CEE_PURE) && !defined(_NATIVE_WCHAR_T_DEFINED) + return true; +#else + return fs::file_size(fs::current_path() / "two.cpp") != 0u; +#endif +} + +int main() { + assert(meow() == 1729 && test_wchar_t_minus()); +} diff --git a/tests/std/tests/Dev09_172666_tr1_tuple_odr/two.cpp b/tests/std/tests/Dev09_172666_tr1_tuple_odr/two.cpp new file mode 100644 index 00000000000..afaf8c39b21 --- /dev/null +++ b/tests/std/tests/Dev09_172666_tr1_tuple_odr/two.cpp @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include <__msvc_all_public_headers.hpp> + +int meow() { + return 1729; +} diff --git a/tests/std/tests/Dev09_173612_tr1_regex_leak/env.lst b/tests/std/tests/Dev09_173612_tr1_regex_leak/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_173612_tr1_regex_leak/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_173612_tr1_regex_leak/test.cpp b/tests/std/tests/Dev09_173612_tr1_regex_leak/test.cpp new file mode 100644 index 00000000000..54abc22c893 --- /dev/null +++ b/tests/std/tests/Dev09_173612_tr1_regex_leak/test.cpp @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +using namespace std; + +#pragma warning(disable : 28251) // Inconsistent annotation for 'new': this instance has no annotations. + +const int N = 1000; + +int g_scalars = 0; +int g_arrays = 0; +void* g_scalar_allocations[N] = {nullptr}; +void* g_array_allocations[N] = {nullptr}; + +void meta_new(void* p, void** allocations, const char* type) { + for (int i = 0; i < N; ++i) { + if (allocations[i] == p) { + printf("meta_new(): The %s allocation %p already exists!\n", type, p); + abort(); + } + } + + for (int i = 0; i < N; ++i) { + if (allocations[i] == nullptr) { + allocations[i] = p; + return; + } + } + + printf("meta_new(): We performed over %d %s allocations!\n", N, type); + abort(); +} + +void scalar_new(void* p) { + meta_new(p, g_scalar_allocations, "scalar"); + ++g_scalars; +} + +void array_new(void* p) { + meta_new(p, g_array_allocations, "array"); + ++g_arrays; +} + +void meta_delete(void* p, void** allocations, const char* type) { + int deallocated = 0; + + for (int i = 0; i < N; ++i) { + if (allocations[i] == p) { + allocations[i] = nullptr; + ++deallocated; + } + } + + if (deallocated == 0) { + printf("meta_delete(): The %s allocation %p doesn't exist!\n", type, p); + abort(); + } + + if (deallocated > 1) { + printf("meta_delete(): The %s allocation %p existed more than once!\n", type, p); + abort(); + } +} + +void scalar_delete(void* p) { + if (p) { + meta_delete(p, g_scalar_allocations, "scalar"); + --g_scalars; + } +} + +void array_delete(void* p) { + if (p) { + meta_delete(p, g_array_allocations, "array"); + --g_arrays; + } +} + + +void* operator new(size_t n) { + void* p = malloc(n ? n : 1); + + if (p == nullptr) { + throw bad_alloc(); + } + + scalar_new(p); + + return p; +} + +void* operator new(size_t n, const nothrow_t&) noexcept { + void* p = malloc(n ? n : 1); + + scalar_new(p); + + return p; +} + +void operator delete(void* p) noexcept { + scalar_delete(p); + + free(p); +} + +void operator delete(void* p, const nothrow_t&) noexcept { + scalar_delete(p); + + free(p); +} + +void* operator new[](size_t n) { + void* p = malloc(n ? n : 1); + + if (p == nullptr) { + throw bad_alloc(); + } + + array_new(p); + + return p; +} + +void* operator new[](size_t n, const nothrow_t&) noexcept { + void* p = malloc(n ? n : 1); + + array_new(p); + + return p; +} + +void operator delete[](void* p) noexcept { + array_delete(p); + + free(p); +} + +void operator delete[](void* p, const nothrow_t&) noexcept { + array_delete(p); + + free(p); +} + + +void test(const char* s) { + const int orig_scalars = g_scalars; + const int orig_arrays = g_arrays; + + { regex r(s); } + + if (g_scalars != orig_scalars) { + printf("test(): %d scalar allocation leak(s)!\n", g_scalars - orig_scalars); + abort(); + } + + if (g_arrays != orig_arrays) { + printf("test(): %d array allocation leak(s)!\n", g_arrays - orig_arrays); + abort(); + } +} + + +int main() { + // Perform any locale allocations before we begin the tests. + locale loc; + use_facet>(loc); + use_facet>(loc); + + test("([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}"); + test("(^[ " + "]*#(?:[^\\\\\\n]|\\\\[^\\n_[:punct:][:alnum:]]*[\\n[:punct:][:w:]])*)|(//[^\\n]*|/\\*.*?\\*/" + ")|\\b([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(" + "?:8|16|32|64))|L)?)\\b|('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|\\b(__asm|__cdecl|__declspec|__" + "export|__far16|__fastcall|__fortran|__import|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_" + "fastcall|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool|break|case|catch|cdecl|" + "char|class|const|const_cast|continue|default|delete|do|double|dynamic_cast|else|enum|explicit|extern|false|" + "float|for|friend|goto|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected|public|" + "register|reinterpret_cast|return|short|signed|sizeof|static|static_cast|struct|switch|template|this|throw|" + "true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\\b"); + test("(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)"); + test("[[:alpha:]]+ing"); + test("^([0-9]+)(\\-| |$)(.*)$"); + test("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[" + "0-9]{1,3})(\\]?)$"); + test("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([ " + "]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?(\\{|:[^;\\{()]*\\{)"); + test("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$"); + test("^[ ]*#[ ]*include[ ]+(\"[^\"]+\"|<[^>]+>)"); + test("^[ ]*#[ ]*include[ ]+(\"boost/[^\"]+\"|]+>)"); + test("^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$"); + test("^[^ ]*?Twain"); + test("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$"); + test("]+href=(\"[^\"]*\"|[^[:space:]]+)[^>]*>"); + test("]+face=(\"[^\"]*\"|[^[:space:]]+)[^>]*>.*?"); + test("]*>.*?"); + test("]+src=(\"[^\"]*\"|[^[:space:]]+)[^>]*>"); + test("

.*?

"); + test("aa"); + test("abc"); + test("Huck[[:alpha:]]+"); + test("Tom|Sawyer|Huckleberry|Finn"); + test("Twain"); +} diff --git a/tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/env.lst b/tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/test.cpp b/tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/test.cpp new file mode 100644 index 00000000000..fb23c6e66f0 --- /dev/null +++ b/tests/std/tests/Dev09_174589_tr1_function_storing_pmf_called_with_reference_or_pointer/test.cpp @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include + +using namespace std; + +struct A { + int f() { + return 8; + } +}; + +void test_orig() { + A a; + A& r = a; + + function f(&A::f); + function g(&A::f); + function h(&A::f); + + assert(f(a) == 8); + assert(g(r) == 8); + assert(h(&a) == 8); +} + + +// DevDiv#294051 ": std::function has lost the ability to invoke PMFs/PMDs on various things" + +// FDIS 20.8.11.2 [func.wrap.func] specifies: +// template class function +// /7 says: +// template function(F f); +// Requires: F shall be CopyConstructible. f shall be Callable (20.8.11.2) for +// argument types ArgTypes and return type R. The copy constructor and +// destructor of A shall not throw exceptions. +// /2 says: +// A callable object f of type F is Callable for argument types ArgTypes and +// return type R if the expression INVOKE(f, declval()..., R), +// considered as an unevaluated operand (Clause 5), is well formed (20.8.2). +// 20.8.2 [func.require]/1-2 says: +// Define INVOKE(f, t1, t2, ..., tN) as follows: +// - (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T +// and t1 is an object of type T or a reference to an object of type T or +// a reference to an object of a type derived from T; +// - ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a class T +// and t1 is not one of the types described in the previous item; +// - t1.*f when N == 1 and f is a pointer to member data of a class T +// and t1 is an object of type T or a reference to an object of type T +// or a reference to an object of a type derived from T; +// - (*t1).*f when N == 1 and f is a pointer to member data of a class T +// and t1 is not one of the types described in the previous item; +// - f(t1, t2, ..., tN) in all other cases. +// Define INVOKE(f, t1, t2, ..., tN, R) as INVOKE(f, t1, t2, ..., tN) implicitly converted to R. + +// Therefore, std::function must be able to invoke PMFs/PMDs +// on values, references, derived references, raw pointers, and smart pointers. + +struct B { + int func(int i) { + return i + data + 5; + } + + int data; +}; + +struct X : public B {}; + +void test_294051() { + shared_ptr b(new B); + shared_ptr x(new X); + + b->data = 220; + x->data = 330; + + function f1 = &B::func; + function f2 = &B::func; + function f3 = &B::func; + function f4 = &B::func; + function f5 = &B::func; + function, int)> f6 = &B::func; + function, int)> f7 = &B::func; + function&, int)> f8 = &B::func; + function&, int)> f9 = &B::func; + + assert(f1(*b, 1000) == 1225); + assert(f2(*b, 2000) == 2225); + assert(f3(*x, 3000) == 3335); + assert(f4(b.get(), 4000) == 4225); + assert(f5(x.get(), 5000) == 5335); + assert(f6(b, 6000) == 6225); + assert(f7(x, 7000) == 7335); + assert(f8(b, 8000) == 8225); + assert(f9(x, 9000) == 9335); + + function g1 = &B::data; + function g2 = &B::data; + function g3 = &B::data; + function g4 = &B::data; + function g5 = &B::data; + function)> g6 = &B::data; + function)> g7 = &B::data; + function&)> g8 = &B::data; + function&)> g9 = &B::data; + + assert(g1(*b) == 220); + assert(g2(*b) == 220); + assert(g3(*x) == 330); + assert(g4(b.get()) == 220); + assert(g5(x.get()) == 330); + assert(g6(b) == 220); + assert(g7(x) == 330); + assert(g8(b) == 220); + assert(g9(x) == 330); +} + + +int main() { + test_orig(); + + test_294051(); +} diff --git a/tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/env.lst b/tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/test.cpp b/tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/test.cpp new file mode 100644 index 00000000000..4adb8ad5a7c --- /dev/null +++ b/tests/std/tests/Dev09_175314_tr1_reference_wrapper_assignment/test.cpp @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; + +int f() { + return 456; +} + +int g() { + return 789; +} + +int main() { + { + int a = 100; + int b = 200; + + int* const pa = &a; + int* const pb = &b; + + reference_wrapper ra(pa); + reference_wrapper rb(pb); + + assert(a == 100 && b == 200); + + *ra += 1; + + assert(a == 101 && b == 200); + + ra = rb; + + *ra += 2; + + assert(a == 101 && b == 202); + } + + { + int (*const pf)() = f; + int (*const pg)() = g; + + reference_wrapper rf(pf); + reference_wrapper rg(pg); + + assert(rf() == 456); + + rf = rg; + + assert(rf() == 789); + } +} diff --git a/tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/env.lst b/tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/test.cpp b/tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/test.cpp new file mode 100644 index 00000000000..dd096ed41a5 --- /dev/null +++ b/tests/std/tests/Dev09_175716_tr1_dereferencing_reference_wrapper/test.cpp @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; + +int main() { + int x = 100; + int* p = &x; + + reference_wrapper r(p); + + *r /= 5; + + assert(x == 20); +} diff --git a/tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/env.lst b/tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/test.cpp b/tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/test.cpp new file mode 100644 index 00000000000..876abf9d4ef --- /dev/null +++ b/tests/std/tests/Dev09_176467_tr1_make_tuple_from_string_literal/test.cpp @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +using namespace std; + +int main() { + tuple t = make_tuple("abc", 10); + + const string s("abc"); + const int i = 10; + + assert(get<0>(t) == s && get<1>(t) == i); +} diff --git a/tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/env.lst b/tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/test.cpp b/tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/test.cpp new file mode 100644 index 00000000000..6696e3a4c14 --- /dev/null +++ b/tests/std/tests/Dev09_176498_tr1_binding_functors_with_non_const_fxn_call_ops/test.cpp @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +using namespace std; + +struct functor { + typedef int result_type; + + int operator()(int x) { // NON-const + return x * 2; + } +}; + +struct nullary { + typedef int result_type; + + int operator()() { // NON-const + return 1729; + } +}; + +int main() { + functor f; // NON-const + + int r1 = bind(f, 123)(); + + assert(r1 == 246); + + nullary g; // NON-const + + int r2 = bind(g)(); + + assert(r2 == 1729); +} diff --git a/tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/env.lst b/tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/env.lst new file mode 100644 index 00000000000..1f3dc81ee8b --- /dev/null +++ b/tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\native_17_matrix.lst diff --git a/tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/test.cpp b/tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/test.cpp new file mode 100644 index 00000000000..9554a5615f7 --- /dev/null +++ b/tests/std/tests/Dev09_181509_tr1_inf_loop_uniform_int_ull/test.cpp @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace std::execution; + +constexpr uint32_t N = 500'000; + +template +void microtest() { + URNG engine; + uniform_int_distribution dist(A, B); + + for (uint32_t i = 0; i < N; ++i) { + const T val = dist(engine); + + assert(val >= A && val <= B); + } +} + +using fp_t = void (*)(); +template +void add_tests(vector& tests) { + // Test DevDiv#83370 "uniform_int_distribution isn't uniform". + tests.insert( + tests.end(), { + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, + + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, + + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, + microtest, // Test DDB#181509 "TR1 VC9 SP1: Infinite loop in + // uniform_int::_Eval()". + microtest, + + microtest, + microtest, + microtest, + microtest, + microtest, + + microtest, + microtest, + microtest, + + microtest, + microtest, + microtest, + microtest, + microtest, + + microtest, + microtest, + microtest, + }); +} + +class Wacky { +public: + Wacky() : mt(1701) {} + + typedef unsigned long result_type; + + static result_type min() { + return 0; + } + + static result_type max() { + return 90000; + } + + result_type operator()() { + for (;;) { + const result_type ret = mt() & 0x1FFFFUL; + + if (ret >= min() && ret <= max()) { + return ret; + } + } + } + +private: + mt19937 mt; +}; + +int main() { + vector tests; + + add_tests(tests); + add_tests(tests); + add_tests(tests); + + for_each(par, tests.begin(), tests.end(), [](fp_t fn) { fn(); }); +} diff --git a/tests/std/tests/Dev09_182017_tr1_search_n/env.lst b/tests/std/tests/Dev09_182017_tr1_search_n/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_182017_tr1_search_n/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_182017_tr1_search_n/test.cpp b/tests/std/tests/Dev09_182017_tr1_search_n/test.cpp new file mode 100644 index 00000000000..f68559a4194 --- /dev/null +++ b/tests/std/tests/Dev09_182017_tr1_search_n/test.cpp @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include + +using namespace std; + +int main() { + { + vector v; + + for (int i = 0; i < 6; ++i) { + v.push_back(i * 5); + } + + for (int i = 0; i < 3; ++i) { + v.push_back(5); + } + + for (int i = 0; i < 6; ++i) { + v.push_back(i * 5); + } + + for (int i = 0; i < 3; ++i) { + v.push_back(5); + } + + assert(search_n(v.begin(), v.end(), 5, 7) == v.end() && "Found 5 occurrences of 7. This is BAD."); + assert(search_n(v.begin(), v.end(), 4, 5) == v.end() && "Found 4 occurrences of 5. This is BAD."); + assert( + search_n(v.begin(), v.end(), 5, 7, equal_to()) == v.end() && "Found 5 occurrences of 7. This is BAD."); + assert( + search_n(v.begin(), v.end(), 4, 5, equal_to()) == v.end() && "Found 4 occurrences of 5. This is BAD."); + } + + { + vector v; + + v.push_back(11); + v.push_back(22); + v.push_back(33); + v.push_back(44); + v.push_back(55); + + assert(search_n(v.rbegin(), v.rend(), 4, 8) == v.rend()); + assert(search_n(v.rbegin(), v.rend(), 4, 8, equal_to()) == v.rend()); + } +} diff --git a/tests/std/tests/Dev09_186118_stoullx_corner_cases/env.lst b/tests/std/tests/Dev09_186118_stoullx_corner_cases/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_186118_stoullx_corner_cases/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_186118_stoullx_corner_cases/test.cpp b/tests/std/tests/Dev09_186118_stoullx_corner_cases/test.cpp new file mode 100644 index 00000000000..edde4cf3d2e --- /dev/null +++ b/tests/std/tests/Dev09_186118_stoullx_corner_cases/test.cpp @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +int main() { + unsigned long long s = 10000000000000000000ULL; + unsigned long long t = 0; + unsigned long u = 1000000000UL; + unsigned long v = 0; + std::stringstream str; + std::stringstream str2; + + str << s; + str >> t; + + assert(str); + assert(s == t); + + str2 << u; + str2 >> v; + + assert(str2); + assert(u == v); +} diff --git a/tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/env.lst b/tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/env.lst new file mode 100644 index 00000000000..19f025bd0e6 --- /dev/null +++ b/tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/env.lst @@ -0,0 +1,4 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +RUNALL_INCLUDE ..\usual_matrix.lst diff --git a/tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/test.cpp b/tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/test.cpp new file mode 100644 index 00000000000..00e9cd27854 --- /dev/null +++ b/tests/std/tests/Dev09_192736_tr1_prngs_not_copyconstructible/test.cpp @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include +#include +#include +#include + +using namespace std; + +template +void test_generator_can_be_value_direct_initialized() { + Gen gen; + + Gen other(gen); + + assert(other == gen); +} + +template +void test_generator_can_be_const_ref_direct_initialized() { + Gen gen; + const Gen& r = gen; + + Gen other(r); + + assert(other == gen); +} + +template +void test_generator_can_be_value_copy_initialized() { + Gen gen; + + Gen other = gen; + + assert(other == gen); +} + +template +void test_generator_can_be_const_ref_copy_initialized() { + Gen gen; + const Gen& r = gen; + + Gen other = r; + + assert(other == gen); +} + +template +void test_generator_can_be_reseeded(ReseedFunc reseedFunc) { + const auto iterations = 100u; + Gen gen; + reseedFunc(gen); + vector firstPassResults; + generate_n(back_inserter(firstPassResults), iterations, ref(gen)); + reseedFunc(gen); + vector seededResults; + generate_n(back_inserter(seededResults), iterations, ref(gen)); + assert(firstPassResults == seededResults); +} + +template +void test_engine() { + test_generator_can_be_value_direct_initialized(); + test_generator_can_be_const_ref_direct_initialized(); + test_generator_can_be_value_copy_initialized(); + test_generator_can_be_const_ref_copy_initialized(); + test_generator_can_be_reseeded([](Gen& gen) { gen.seed(); }); + test_generator_can_be_reseeded([](Gen& gen) { gen.seed(1729); }); +} + +template +void test_distribution_can_be_reset(Dist dist) { + knuth_b gen; + const auto iterations = 100u; + vector firstPassResults; + generate_n(back_inserter(firstPassResults), iterations, [&]() { return dist(gen); }); + dist.reset(); + gen.seed(); + vector resetResults; + generate_n(back_inserter(resetResults), iterations, [&]() { return dist(gen); }); + assert(firstPassResults == resetResults); +} + +template +void test_distribution(Dist dist) { + test_distribution_can_be_reset(dist); +} + +template