Skip to content
Snippets Groups Projects
Commit c164c457 authored by Ralf Mueller's avatar Ralf Mueller
Browse files

put all test under libcheck

parent a8b6bafe
No related branches found
No related tags found
No related merge requests found
......@@ -574,6 +574,77 @@ START_TEST(test_mtime_add_months)
}
END_TEST
/**
* check adding negative time periods
*/
START_TEST(test_add_negative_delta)
{
struct _datetime *dummy;
struct _datetime *init = newDateTime("1111-11-11T00:00:00.000");
struct _timedelta *delta = newTimeDelta("PT10M");
struct _timedelta *minusdelta = newTimeDelta("-PT10M");
char init_s[MAX_DATETIME_STR_LEN];
ck_assert_str_eq("1111-11-11T00:10:00.000",datetimeToString(addTimeDeltaToDateTime(init,delta,init),init_s));
ck_assert_str_eq("1111-11-11T00:20:00.000",datetimeToString(addTimeDeltaToDateTime(init,delta,init),init_s));
ck_assert_str_eq("1111-11-11T00:10:00.000",datetimeToString(addTimeDeltaToDateTime(init,minusdelta,init),init_s));
ck_assert_str_eq("1111-11-11T00:00:00.000",datetimeToString(addTimeDeltaToDateTime(init,minusdelta,init),init_s));
}
END_TEST
/**
* test events created with offset to trigger 10 minutes before end of months
*/
START_TEST(test_event_at_end_of_month)
{
/* some lines stolen from model_integrate.c */
char current_time[MAX_DATETIME_STR_LEN]; // Again, we use *STR_LEN.
char current_step[MAX_TIMEDELTA_STR_LEN]; // and here too.
struct _timedelta *timestep = newTimeDelta("PT10M");
struct _datetime *dummy;
struct _datetime *start_date = newDateTime("2013-01-01T00:00:00.000");
struct _datetime *stop_date = newDateTime("2014-03-03T14:00:00.000");
struct _datetime *model_time = newDateTime("2013-01-01T00:00:00.000");
struct _event* out = newEvent("outputEvent",
"2013-01-01T00:00:00.000",
"2013-01-01T00:00:00.000",
"2019-01-01T00:00:00.000",
"P1M",
NULL);
struct _event* outAtEnd = newEvent("outputEventAtEnd",
"2012-12-31T23:50:00.000",
"2013-01-01T00:00:00.000",
"2019-01-01T00:00:00.000",
"P1M",
NULL);
#ifdef EBUG
printf("Model time step: %s\n", timedeltaToString(timestep, current_step));
printf("Model start time: %s\n\n", datetimeToString(model_time, current_time));
#endif
do
{
/* check if outputEvent is active */
dummy = addTimeDeltaToDateTime(model_time,newTimeDelta("PT10"),dummy);
bool activeOut = isCurrentEventActive(out,model_time, NULL, NULL);
bool activeOutShift = isCurrentEventActive(out,dummy , NULL, NULL);
bool activeOutAtEnd = isCurrentEventActive(outAtEnd,model_time, NULL, NULL);
#ifdef EBUG
if (activeOut || activeOutAtEnd || activeOutShift) printf("Model time: %s ", datetimeToString(model_time, current_time));
if (activeOut) printf("outputEvent active! ");
if (activeOutAtEnd) printf("outputEventAtEnd active!");
if (activeOutShift) printf("outputShifted active!");
if (activeOut || activeOutAtEnd ) printf("\n");
#endif
addTimeDeltaToDateTime(model_time, timestep, model_time); /* Increment time by timestep. */
} while (compareDatetime(model_time, stop_date) <= 0);
}
END_TEST
static void setup_ProlepticGregorian(void)
{
initCalendar(PROLEPTIC_GREGORIAN);
......@@ -624,6 +695,8 @@ void add_mtime_timedelta_test_to_suite(Suite* suite)
tcase_add_test(tcase_timedeltaCompute,test_timeDeltaAddLeadingZero);
tcase_add_test(tcase_timedeltaCompute,test_mtime_add_months);
tcase_add_test(tcase_timedeltaCompute,test_mtime_add_months_atEnd);
tcase_add_test(tcase_timedeltaCompute,test_add_negative_delta);
tcase_add_test(tcase_timedeltaCompute,test_event_at_end_of_month);
tcase_add_test(tcase_timedeltaCompute,test_timeDeltaMilliseconds);
}
......
......@@ -403,8 +403,8 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
@DX_COND_doc_FALSE@mostlyclean-local:
@DX_COND_doc_FALSE@install-data-local:
@DX_COND_doc_FALSE@mostlyclean-local:
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment