File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 21
21
#include " mbed.h"
22
22
#include " mbed_mktime.h"
23
23
24
+ // Limit the test range to 1935 for IAR only. From the IAR C/C++ Development Guide:
25
+ // "The 32-bit interface supports years from 1900 up to 2035 and uses a 32-bit integer
26
+ // for time_t."
27
+ #ifdef __ICCARM__
28
+ #define LOCALTIME_MAX 2082758400 // 1st of january 2036 at 00:00:00
29
+ #define MKTIME_YR_MAX 136
30
+ #else
31
+ #define LOCALTIME_MAX INT_MAX
32
+ #define MKTIME_YR_MAX 137
33
+ #endif
34
+
24
35
using namespace utest ::v1;
25
36
26
37
/*
@@ -116,7 +127,7 @@ void test_mk_time_out_of_range() {
116
127
* test mktime over a large set of values
117
128
*/
118
129
void test_mk_time () {
119
- for (size_t year = 70 ; year < 137 ; ++year) {
130
+ for (size_t year = 70 ; year < MKTIME_YR_MAX ; ++year) {
120
131
for (size_t month = 0 ; month < 12 ; ++month) {
121
132
for (size_t day = 1 ; day < 32 ; ++day) {
122
133
if (month == 1 && is_leap_year (year) && day == 29 ) {
@@ -172,7 +183,7 @@ void test_local_time_limit() {
172
183
* test _rtc_localtime over a large set of values.
173
184
*/
174
185
void test_local_time () {
175
- for (uint32_t i = 0 ; i < INT_MAX ; i += 3451 ) {
186
+ for (uint32_t i = 0 ; i < LOCALTIME_MAX ; i += 3451 ) {
176
187
time_t copy = (time_t ) i;
177
188
struct tm * expected = localtime (©);
178
189
struct tm actual_value;
You can’t perform that action at this time.
0 commit comments