Skip to content

Commit fee1343

Browse files
0.9.41-alpha
1 parent 0ca6179 commit fee1343

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

testlib.h

+69-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
#define _TESTLIB_H_
2323

2424
/*
25-
* Copyright (c) 2005-2022
25+
* Copyright (c) 2005-2023
2626
*/
2727

28-
#define VERSION "0.9.40-SNAPSHOT"
28+
#define VERSION "0.9.41-alpha"
2929

3030
/*
3131
* Mike Mirzayanov
@@ -63,6 +63,10 @@
6363
*/
6464

6565
const char *latestFeatures[] = {
66+
"Use setAppesModeEncoding to change xml encoding from windows-1251 to other",
67+
"rnd.any/wany use distance/advance instead of -/+: now they support sets/multisets",
68+
"Use syntax `int t = inf.readInt(1, 3, \"~t\");` to skip the lower bound check. Tildes can be used on either side or both: ~t, t~, ~t~",
69+
"Supported EJUDGE support in registerTestlibCmd",
6670
"Supported '--testMarkupFileName fn' and '--testCase tc/--testCaseFileName fn' for validators",
6771
"Added opt defaults via opt<T>(key/index, default_val); check unused opts when using has_opt or default opt (turn off this check with suppressEnsureNoUnusedOpt()).",
6872
"For checker added --group and --testset command line params (like for validator), use checker.group() or checker.testset() to get values",
@@ -343,25 +347,40 @@ void unsetTestCase() {
343347
NORETURN static void __testlib_fail(const std::string &message);
344348

345349
template<typename T>
350+
#ifdef __GNUC__
351+
__attribute__((const))
352+
#endif
346353
static inline T __testlib_abs(const T &x) {
347354
return x > 0 ? x : -x;
348355
}
349356

350357
template<typename T>
358+
#ifdef __GNUC__
359+
__attribute__((const))
360+
#endif
351361
static inline T __testlib_min(const T &a, const T &b) {
352362
return a < b ? a : b;
353363
}
354364

355365
template<typename T>
366+
#ifdef __GNUC__
367+
__attribute__((const))
368+
#endif
356369
static inline T __testlib_max(const T &a, const T &b) {
357370
return a > b ? a : b;
358371
}
359372

360373
template<typename T>
374+
#ifdef __GNUC__
375+
__attribute__((const))
376+
#endif
361377
static inline T __testlib_crop(T value, T a, T b) {
362378
return __testlib_min(__testlib_max(value, a), --b);
363379
}
364380

381+
#ifdef __GNUC__
382+
__attribute__((const))
383+
#endif
365384
static inline double __testlib_crop(double value, double a, double b) {
366385
value = __testlib_min(__testlib_max(value, a), b);
367386
if (value >= b)
@@ -378,6 +397,9 @@ static bool __testlib_prelimIsNaN(double r) {
378397
#endif
379398
}
380399

400+
#ifdef __GNUC__
401+
__attribute__((const))
402+
#endif
381403
static std::string removeDoubleTrailingZeroes(std::string value) {
382404
while (!value.empty() && value[value.length() - 1] == '0' && value.find('.') != std::string::npos)
383405
value = value.substr(0, value.length() - 1);
@@ -387,13 +409,19 @@ static std::string removeDoubleTrailingZeroes(std::string value) {
387409
return value;
388410
}
389411

412+
#ifdef __GNUC__
413+
__attribute__((const))
414+
#endif
390415
inline std::string upperCase(std::string s) {
391416
for (size_t i = 0; i < s.length(); i++)
392417
if ('a' <= s[i] && s[i] <= 'z')
393418
s[i] = char(s[i] - 'a' + 'A');
394419
return s;
395420
}
396421

422+
#ifdef __GNUC__
423+
__attribute__((const))
424+
#endif
397425
inline std::string lowerCase(std::string s) {
398426
for (size_t i = 0; i < s.length(); i++)
399427
if ('A' <= s[i] && s[i] <= 'Z')
@@ -414,6 +442,9 @@ std::string format(const std::string fmt, ...) {
414442
return result;
415443
}
416444

445+
#ifdef __GNUC__
446+
__attribute__((const))
447+
#endif
417448
static std::string __testlib_part(const std::string &s);
418449

419450
static bool __testlib_isNaN(double r) {
@@ -532,6 +563,9 @@ static void __testlib_set_binary(std::FILE *file) {
532563

533564
#if __cplusplus > 199711L || defined(_MSC_VER)
534565
template<typename T>
566+
#ifdef __GNUC__
567+
__attribute__((const))
568+
#endif
535569
static std::string vtos(const T &t, std::true_type) {
536570
if (t == 0)
537571
return "0";
@@ -3297,6 +3331,9 @@ void InStream::readTokenTo(std::string &result) {
32973331
readWordTo(result);
32983332
}
32993333

3334+
#ifdef __GNUC__
3335+
__attribute__((const))
3336+
#endif
33003337
static std::string __testlib_part(const std::string &s) {
33013338
std::string t;
33023339
for (size_t i = 0; i < s.length(); i++)
@@ -4824,10 +4861,16 @@ void startTest(int test) {
48244861
__testlib_fail("Unable to write file '" + testFileName + "'");
48254862
}
48264863

4864+
#ifdef __GNUC__
4865+
__attribute__((const))
4866+
#endif
48274867
inline std::string compress(const std::string &s) {
48284868
return __testlib_part(s);
48294869
}
48304870

4871+
#ifdef __GNUC__
4872+
__attribute__((const))
4873+
#endif
48314874
inline std::string englishEnding(int x) {
48324875
x %= 100;
48334876
if (x / 10 == 1)
@@ -4842,6 +4885,9 @@ inline std::string englishEnding(int x) {
48424885
}
48434886

48444887
template<typename _ForwardIterator, typename _Separator>
4888+
#ifdef __GNUC__
4889+
__attribute__((const))
4890+
#endif
48454891
std::string join(_ForwardIterator first, _ForwardIterator last, _Separator separator) {
48464892
std::stringstream ss;
48474893
bool repeated = false;
@@ -4856,16 +4902,25 @@ std::string join(_ForwardIterator first, _ForwardIterator last, _Separator separ
48564902
}
48574903

48584904
template<typename _ForwardIterator>
4905+
#ifdef __GNUC__
4906+
__attribute__((const))
4907+
#endif
48594908
std::string join(_ForwardIterator first, _ForwardIterator last) {
48604909
return join(first, last, ' ');
48614910
}
48624911

48634912
template<typename _Collection, typename _Separator>
4913+
#ifdef __GNUC__
4914+
__attribute__((const))
4915+
#endif
48644916
std::string join(const _Collection &collection, _Separator separator) {
48654917
return join(collection.begin(), collection.end(), separator);
48664918
}
48674919

48684920
template<typename _Collection>
4921+
#ifdef __GNUC__
4922+
__attribute__((const))
4923+
#endif
48694924
std::string join(const _Collection &collection) {
48704925
return join(collection, ' ');
48714926
}
@@ -4874,6 +4929,9 @@ std::string join(const _Collection &collection) {
48744929
* Splits string s by character separator returning exactly k+1 items,
48754930
* where k is the number of separator occurrences.
48764931
*/
4932+
#ifdef __GNUC__
4933+
__attribute__((const))
4934+
#endif
48774935
std::vector<std::string> split(const std::string &s, char separator) {
48784936
std::vector<std::string> result;
48794937
std::string item;
@@ -4891,6 +4949,9 @@ std::vector<std::string> split(const std::string &s, char separator) {
48914949
* Splits string s by character separators returning exactly k+1 items,
48924950
* where k is the number of separator occurrences.
48934951
*/
4952+
#ifdef __GNUC__
4953+
__attribute__((const))
4954+
#endif
48944955
std::vector<std::string> split(const std::string &s, const std::string &separators) {
48954956
if (separators.empty())
48964957
return std::vector<std::string>(1, s);
@@ -4914,6 +4975,9 @@ std::vector<std::string> split(const std::string &s, const std::string &separato
49144975
/**
49154976
* Splits string s by character separator returning non-empty items.
49164977
*/
4978+
#ifdef __GNUC__
4979+
__attribute__((const))
4980+
#endif
49174981
std::vector<std::string> tokenize(const std::string &s, char separator) {
49184982
std::vector<std::string> result;
49194983
std::string item;
@@ -4932,6 +4996,9 @@ std::vector<std::string> tokenize(const std::string &s, char separator) {
49324996
/**
49334997
* Splits string s by character separators returning non-empty items.
49344998
*/
4999+
#ifdef __GNUC__
5000+
__attribute__((const))
5001+
#endif
49355002
std::vector<std::string> tokenize(const std::string &s, const std::string &separators) {
49365003
if (separators.empty())
49375004
return std::vector<std::string>(1, s);

0 commit comments

Comments
 (0)