]> mj.ucw.cz Git - libucw.git/commitdiff
xtypes&tableprinter: fix of tests of parsing
authorRobert Kessl <kesslr@centrum.cz>
Wed, 23 Jul 2014 12:10:14 +0000 (14:10 +0200)
committerRobert Kessl <kesslr@centrum.cz>
Wed, 23 Jul 2014 12:10:14 +0000 (14:10 +0200)
ucw/table-types.c
ucw/xtypes-test.c
ucw/xtypes-test.t

index 1d3130b791206d09c006b9a7f27751cdfe3ce065..4197fa3d69212a7a2a8613b501bc6af6b1c20a34 100644 (file)
@@ -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);
   }
index 2419cb187108992d9e8be40fd0dfd2d77905fab3..9ed3461182017dfcc58a1e4b400832bb3677bc7b 100644 (file)
@@ -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;
index 41768fb98b84705d5005c3de90690cb257913e5c..467754758d8aebc52df5a75d7c4e93105f8c0143 100644 (file)
@@ -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