Limit mktime test range for IAR

Do not test mktime or localtime past the year 1935 for IAR since this
is out of their supported range.
pull/4519/head
Russ Butler 2017-06-09 16:23:40 -05:00
parent 761151359e
commit d6af53c3ab
1 changed files with 13 additions and 2 deletions

View File

@ -21,6 +21,17 @@
#include "mbed.h"
#include "mbed_mktime.h"
// Limit the test range to 1935 for IAR only. From the IAR C/C++ Development Guide:
// "The 32-bit interface supports years from 1900 up to 2035 and uses a 32-bit integer
// for time_t."
#ifdef __ICCARM__
#define LOCALTIME_MAX 2082758400 // 1st of january 2036 at 00:00:00
#define MKTIME_YR_MAX 136
#else
#define LOCALTIME_MAX INT_MAX
#define MKTIME_YR_MAX 137
#endif
using namespace utest::v1;
/*
@ -116,7 +127,7 @@ void test_mk_time_out_of_range() {
* test mktime over a large set of values
*/
void test_mk_time() {
for (size_t year = 70; year < 137; ++year) {
for (size_t year = 70; year < MKTIME_YR_MAX; ++year) {
for (size_t month = 0; month < 12; ++month) {
for (size_t day = 1; day < 32; ++day) {
if (month == 1 && is_leap_year(year) && day == 29) {
@ -172,7 +183,7 @@ void test_local_time_limit() {
* test _rtc_localtime over a large set of values.
*/
void test_local_time() {
for (uint32_t i = 0; i < INT_MAX; i += 3451) {
for (uint32_t i = 0; i < LOCALTIME_MAX; i += 3451) {
time_t copy = (time_t) i;
struct tm* expected = localtime(&copy);
struct tm actual_value;