Check Datetime addition when performing recurrence (#3708)

This commit is contained in:
Dustin J. Mitchell 2024-11-29 09:12:20 -05:00 committed by GitHub
parent 0b286460b6
commit 4797c4e17e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 6 deletions

View file

@ -33,6 +33,7 @@
#include <util.h>
#include <iostream>
#include <limits>
////////////////////////////////////////////////////////////////////////////////
int TEST_NAME(int, char**) {
@ -91,6 +92,12 @@ int TEST_NAME(int, char**) {
t.ok(nontrivial(" \t\ta"), "nontrivial ' \\t\\ta' -> true");
t.ok(nontrivial("a\t\t "), "nontrivial 'a\\t\\t ' -> true");
Datetime dt(1234526400);
Datetime max(std::numeric_limits<time_t>::max());
t.ok(checked_add_datetime(dt, 10).has_value(), "small delta");
t.ok(!checked_add_datetime(dt, 0x100000000).has_value(), "delta > 32bit");
t.ok(!checked_add_datetime(max, 1).has_value(), "huge base time");
return 0;
}