From 9578cd5b540fa8c0e0449e4b5e41fba516c7e5ad Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Mon, 24 Feb 2020 14:40:58 +0100 Subject: [PATCH] tests: improve coverage Change-Id: Ia252acaea242ff924e3c20bbbe817a5e82f9140a Signed-off-by: Michal Bloch --- src/tests/queued_entry.c | 5 +++++ src/tests/test_common.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/tests/queued_entry.c b/src/tests/queued_entry.c index 476fdc9..6af04d5 100644 --- a/src/tests/queued_entry.c +++ b/src/tests/queued_entry.c @@ -41,6 +41,8 @@ int main() { "sent_mono", DLOGUTIL_SORT_SENT_MONO }, { "recv_real", DLOGUTIL_SORT_RECV_REAL }, { "recv_mono", DLOGUTIL_SORT_RECV_MONO }, + { "default", DLOGUTIL_SORT_RECV_MONO }, + { "x_invalid", DLOGUTIL_SORT_RECV_MONO }, }; for (size_t i = 0; i < NELEMS(ordering); ++i) { log_config_set(&conf, "sort_by", ordering[i].str); @@ -71,6 +73,9 @@ int main() assert(ts.tv_sec == le. sec_recv_mono); assert(ts.tv_nsec == le.nsec_recv_mono); + assert(dlogutil_entry_get_timestamp(NULL, DLOGUTIL_SORT_RECV_MONO, &ts) == TIZEN_ERROR_INVALID_PARAMETER); + assert(dlogutil_entry_get_timestamp(&le, DLOGUTIL_SORT_RECV_MONO, NULL) == TIZEN_ERROR_INVALID_PARAMETER); + // invalid entries always compare false (kinda like NaN floats) const dlogutil_entry_s invalid_1 = { .nsec_sent_mono = -1 }; const dlogutil_entry_s invalid_2 = { .nsec_sent_mono = -1 }; diff --git a/src/tests/test_common.c b/src/tests/test_common.c index 17545e3..6a78a0b 100644 --- a/src/tests/test_common.c +++ b/src/tests/test_common.c @@ -278,6 +278,23 @@ int main(int argc, char **argv) { struct { + const char *str; + dlogutil_sorting_order_e result; + } const test_cases[] = { + { "sent_real", DLOGUTIL_SORT_SENT_REAL }, + { "sent_mono", DLOGUTIL_SORT_SENT_MONO }, + { "recv_real", DLOGUTIL_SORT_RECV_REAL }, + { "recv_mono", DLOGUTIL_SORT_RECV_MONO }, + { "default", DLOGUTIL_SORT_DEFAULT }, + { "x_invalid", DLOGUTIL_SORT_DEFAULT }, + { "", DLOGUTIL_SORT_DEFAULT }, + }; + for (size_t i = 0; i < NELEMS(test_cases); ++i) + assert(test_cases[i].result == get_order_from_string(test_cases[i].str)); + } + + { + struct { bool result; const char *ending; } const test_cases[] = { -- 2.7.4