From 5806618cb721e5bfc9a77cb85d832fadf3700cc1 Mon Sep 17 00:00:00 2001 From: Robert Kessl Date: Wed, 23 Jul 2014 14:10:14 +0200 Subject: [PATCH] xtypes&tableprinter: fix of tests of parsing --- ucw/table-types.c | 2 +- ucw/xtypes-test.c | 9 +++++---- ucw/xtypes-test.t | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ucw/table-types.c b/ucw/table-types.c index 1d3130b7..4197fa3d 100644 --- a/ucw/table-types.c +++ b/ucw/table-types.c @@ -178,7 +178,7 @@ static const char *xt_timestamp_parse(const char *str, void *dest, struct mempoo struct tm parsed_time; //"%Y-%m-%d %H:%M:%S" //"%F %T" - parse_end = strptime("%F %T", "%Y-%m-%d %H:%M:%S", &parsed_time); + parse_end = strptime(str, "%F %T", &parsed_time); if(parse_end == NULL) { return mp_printf(pool, "Invalid value of timestamp: '%s'.", str); } diff --git a/ucw/xtypes-test.c b/ucw/xtypes-test.c index 2419cb18..9ed34611 100644 --- a/ucw/xtypes-test.c +++ b/ucw/xtypes-test.c @@ -123,7 +123,7 @@ static void test_timestamp_parse_correct(struct fastbuf *out) static u64 timestamp_parsed[] = { 1403685533, - 1403685533, + 1403678333, }; struct mempool *pool = mp_new(4096); @@ -131,7 +131,7 @@ static void test_timestamp_parse_correct(struct fastbuf *out) while(timestamp_strs[i]) { u64 result; - const char *err_str = xt_size.parse(timestamp_strs[i], &result, pool); + const char *err_str = xt_timestamp.parse(timestamp_strs[i], &result, pool); ASSERT_MSG(err_str == NULL, "Unexpected error in xt_size.parse: %s", err_str); ASSERT_MSG(timestamp_parsed[i] == result, "Expected: %" PRIu64 " but got %" PRIu64, timestamp_parsed[i], result); bprintf(out, "%" PRIu64 " %" PRIu64 "\n", timestamp_parsed[i], result); @@ -142,7 +142,7 @@ static void test_timestamp_parse_correct(struct fastbuf *out) mp_delete(pool); } -static void test_timestamp_parse_errors(struct fastbuf *out UNUSED) +static void test_timestamp_parse_errors(struct fastbuf *out) { static const char *timestamp_strs[] = { "1403685533X", @@ -157,7 +157,7 @@ static void test_timestamp_parse_errors(struct fastbuf *out UNUSED) while(timestamp_strs[i]) { u64 result; - const char *err_str = xt_size.parse(timestamp_strs[i], &result, pool); + const char *err_str = xt_timestamp.parse(timestamp_strs[i], &result, pool); if(err_str == NULL) { bprintf(out, "xt_timestamp.parse incorrectly did not result in error while parsing: '%s'.\n", timestamp_strs[i]); @@ -184,6 +184,7 @@ int main(void) test_size_parse_errors(out); test_bool_parse_correct(out); test_timestamp_parse_correct(out); + test_timestamp_parse_errors(out); bclose(out); return 0; diff --git a/ucw/xtypes-test.t b/ucw/xtypes-test.t index 41768fb9..46775475 100644 --- a/ucw/xtypes-test.t +++ b/ucw/xtypes-test.t @@ -12,4 +12,10 @@ xt_size.parse error: 'Invalid value of size: ''.'. 1 true false false true true +1403685533 1403685533 +1403678333 1403678333 +xt_timestamp.parse error: 'Invalid value of timestamp: '1403685533X'.'. +xt_timestamp.parse error: 'Invalid value of timestamp: '2014X-06-25 08:38:53'.'. +xt_timestamp.parse error: 'Invalid value of timestamp: '2X014-06-25 08:38:53'.'. +xt_timestamp.parse error: 'Invalid value of timestamp: 'X1403685533'.'. EOF -- 2.39.2