From a1b31a1f0c761948def4b881f09322407b0b0875 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 30 May 2019 10:34:25 +0100 Subject: [PATCH] test: improve test_mutt_date_localtime_format() --- mutt/date.c | 2 +- mutt/date.h | 2 +- test/date/mutt_date_localtime_format.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mutt/date.c b/mutt/date.c index a89e41a1d..b226c09cc 100644 --- a/mutt/date.c +++ b/mutt/date.c @@ -751,7 +751,7 @@ struct tm mutt_date_gmtime(time_t t) * @param t Time to format * @retval num Number of Bytes added to buffer, excluding null byte. */ -size_t mutt_date_localtime_format(char *buf, size_t buflen, char *format, time_t t) +size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t) { if (!buf || !format) return 0; diff --git a/mutt/date.h b/mutt/date.h index 2637d99eb..20aa991c9 100644 --- a/mutt/date.h +++ b/mutt/date.h @@ -50,7 +50,7 @@ time_t mutt_date_add_timeout(time_t now, long timeout); int mutt_date_check_month(const char *s); struct tm mutt_date_gmtime(time_t t); bool mutt_date_is_day_name(const char *s); -size_t mutt_date_localtime_format(char *buf, size_t buflen, char *format, time_t t); +size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t); struct tm mutt_date_localtime(time_t t); time_t mutt_date_local_tz(time_t t); char * mutt_date_make_date(char *buf, size_t buflen); diff --git a/test/date/mutt_date_localtime_format.c b/test/date/mutt_date_localtime_format.c index 5e17310ad..cbe00ae59 100644 --- a/test/date/mutt_date_localtime_format.c +++ b/test/date/mutt_date_localtime_format.c @@ -37,4 +37,12 @@ void test_mutt_date_localtime_format(void) char buf[32] = { 0 }; TEST_CHECK(mutt_date_localtime_format(buf, sizeof(buf), NULL, 0) == 0); } + + { + char buf[64] = { 0 }; + time_t t = 961930800; + const char *format = "%Y-%m-%d %H:%M:%S"; + TEST_CHECK(mutt_date_localtime_format(buf, sizeof(buf), format, t) > 0); + TEST_CHECK(strcmp(buf, "2000-06-25 12:00:00") == 0); + } } -- 2.40.0