2222#define _TESTLIB_H_
2323
2424/*
25- * Copyright (c) 2005-2025
25+ * Copyright (c) 2005-2026
2626 */
2727
28- #define VERSION " 0.9.45 "
28+ #define VERSION " 0.9.46 "
2929
3030/*
3131 * Mike Mirzayanov
6363 */
6464
6565const char *latestFeatures[] = {
66+ " Dirty fixes to use testlib println/format" ,
6667 " Remove incorrect const attributes" ,
6768 " Added ConstantBoundsLog, VariablesLog to validator testOverviewLogFile" ,
6869 " Use setAppesModeEncoding to change xml encoding from windows-1251 to other" ,
@@ -164,6 +165,14 @@ const char *latestFeatures[] = {
164165#define _CRT_NO_VA_START_VALIDATION
165166#endif
166167
168+ #if __has_include(<format>)
169+ #include < format>
170+ #endif
171+
172+ #if __has_include(<print>)
173+ #include < print>
174+ #endif
175+
167176/* Overrides random() for Borland C++. */
168177#define random __random_deprecated
169178#include < stdlib.h>
@@ -5321,6 +5330,14 @@ struct is_iterator<T, typename __testlib_enable_if<std::is_array<T>::value>::typ
53215330 static const bool value = false ;
53225331};
53235332
5333+ #if defined(__cpp_lib_print) || (defined(__cplusplus) && __cplusplus >= 202302L)
5334+ #define TESTLIB_NEEDS_PRINTLN_FIX
5335+ #endif
5336+
5337+ #ifdef TESTLIB_NEEDS_PRINTLN_FIX
5338+ #define println __testlib_println_impl
5339+ #endif
5340+
53245341template <typename A, typename B>
53255342typename __testlib_enable_if<!is_iterator<B>::value, void >::type println (const A &a, const B &b) {
53265343 __testlib_print_one (a);
@@ -5347,6 +5364,10 @@ void println<char>(const char *a, const char *b) {
53475364 std::cout << std::endl;
53485365}
53495366
5367+ void println () {
5368+ std::cout << std::endl;
5369+ }
5370+
53505371template <typename T>
53515372void println (const T &x) {
53525373 __testlib_print_one (x);
@@ -5423,6 +5444,11 @@ void println(const A &a, const B &b, const C &c, const D &d, const E &e, const F
54235444 std::cout << std::endl;
54245445}
54255446
5447+ #ifdef TESTLIB_NEEDS_PRINTLN_FIX
5448+ #undef println
5449+ #define println (...) __testlib_println_impl(__VA_ARGS__)
5450+ #endif
5451+
54265452/* opts */
54275453
54285454/* *
@@ -6218,7 +6244,12 @@ std::string testlib_format_(const std::string fmt, ...) {
62186244 return result;
62196245}
62206246
6221- #if (__cplusplus >= 202002L && __has_include(<format>)) || __cpp_lib_format
6247+ #if defined(__cpp_lib_format) || (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
6248+ #define TESTLIB_NEEDS_FORMAT_FIX
6249+ #endif
6250+
6251+ #ifdef TESTLIB_NEEDS_PRINTLN_FIX
6252+ #define format __testlib_format_impl
62226253template <typename ... Args>
62236254std::string format (const char * fmt, Args&&... args) {
62246255 size_t size = size_t (std::snprintf (nullptr , 0 , fmt, args...) + 1 );
@@ -6248,5 +6279,9 @@ std::string format(const std::string fmt, ...) {
62486279 return result;
62496280}
62506281#endif
6282+ #ifdef TESTLIB_NEEDS_FORMAT_FIX
6283+ #undef format
6284+ #define format (...) __testlib_format_impl(__VA_ARGS__)
6285+ #endif
62516286
62526287#endif
0 commit comments