Skip to content

Commit 8554703

Browse files
Merge pull request MikeMirzayanov#210 from MikeMirzayanov/better-quitp
Better quitp
2 parents d0a0161 + 7805559 commit 8554703

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

testlib.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,9 +4277,26 @@ NORETURN void quit(TResult result, const char *msg) {
42774277
ouf.quit(result, msg);
42784278
}
42794279

4280+
double __testlib_preparePoints(double points_) {
4281+
volatile double points = points_;
4282+
if (__testlib_isNaN(points))
4283+
quit(_fail, "Parameter 'points' can't be nan");
4284+
if (__testlib_isInfinite(points))
4285+
quit(_fail, "Parameter 'points' can't be infinite");
4286+
if (points < -1E-8)
4287+
quit(_fail, "Parameter 'points' can't be negative");
4288+
if (points <= 0.0)
4289+
points = +0.0;
4290+
if (points > 1E6 + 1E-8)
4291+
quit(_fail, "Parameter 'points' can't be greater than 1E6");
4292+
if (points >= 1E6)
4293+
points = 1E6;
4294+
return points;
4295+
}
4296+
42804297
NORETURN void __testlib_quitp(double points, const char *message) {
4281-
__testlib_points = points;
4282-
std::string stringPoints = removeDoubleTrailingZeroes(format("%.10f", points));
4298+
__testlib_points = __testlib_preparePoints(points);
4299+
std::string stringPoints = removeDoubleTrailingZeroes(format("%.10f", __testlib_points));
42834300

42844301
std::string quitMessage;
42854302
if (NULL == message || 0 == strlen(message))
@@ -4291,7 +4308,7 @@ NORETURN void __testlib_quitp(double points, const char *message) {
42914308
}
42924309

42934310
NORETURN void __testlib_quitp(int points, const char *message) {
4294-
__testlib_points = points;
4311+
__testlib_points = __testlib_preparePoints(points);
42954312
std::string stringPoints = format("%d", points);
42964313

42974314
std::string quitMessage;

0 commit comments

Comments
 (0)