]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/xtypes-test.c
Tests: xtypes-test sets an explicit timezone
[libucw.git] / ucw / xtypes-test.c
index 953020366477426ae9e5616bf6acca2fa282b49e..b8cbe32a6df6a9a96c100160fea8d78511fa7e0a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     UCW Library -- Test of Tableprinter Types
+ *     UCW Library -- Test of Extended Types
  *
  *     (c) 2014 Robert Kessl <robert.kessl@economia.cz>
  *
 #include <ucw/lib.h>
 #include <ucw/mempool.h>
 #include <ucw/xtypes.h>
-#include <ucw/table-types.h>
+#include <ucw/xtypes-extra.h>
 
 #include <errno.h>
-#include <stdlib.h>
 #include <inttypes.h>
+#include <stdlib.h>
+#include <time.h>
 
 static void test_size_parse_correct(struct fastbuf *out)
 {
@@ -134,9 +135,17 @@ static void test_timestamp_parse_correct(struct fastbuf *out)
 
   static u64 timestamp_parsed[] = {
     1403685533,
-    1403678333,
+    0,
   };
 
+  // fill the value of timestamp_parsed as the timestamp in the
+  // current time zone.
+  {
+    struct tm parsed_time;
+    strptime(timestamp_strs[1], "%F %T", &parsed_time);
+    timestamp_parsed[1] = mktime(&parsed_time);
+  }
+
   struct mempool *pool = mp_new(4096);
   uint i = 0;
 
@@ -193,6 +202,7 @@ static void test_timestamp_parse_errors(struct fastbuf *out)
 
 int main(void)
 {
+  setenv("TZ", "Europe/Prague", 1);
   struct fastbuf *out;
   out = bfdopen_shared(1, 4096);