Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libmtime
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icon-libraries
libmtime
Commits
c164c457
Commit
c164c457
authored
9 years ago
by
Ralf Mueller
Browse files
Options
Downloads
Patches
Plain Diff
put all test under libcheck
parent
a8b6bafe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
check/mtime_timedelta_test.c
+73
-0
73 additions, 0 deletions
check/mtime_timedelta_test.c
doc/Makefile.in
+1
-1
1 addition, 1 deletion
doc/Makefile.in
with
74 additions
and
1 deletion
check/mtime_timedelta_test.c
+
73
−
0
View file @
c164c457
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
doc/Makefile.in
+
1
−
1
View file @
c164c457
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment