OSSP CVS Repository

ossp - Difference in ossp-pkg/tai/tai_test.c versions 1.2 and 1.3
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/tai/tai_test.c 1.2 -> 1.3

--- tai_test.c   2002/05/01 18:48:34     1.2
+++ tai_test.c   2002/05/29 08:32:53     1.3
@@ -123,14 +123,46 @@
     tai_destroy(tm);
 }
 
-TS_TEST(test_formatting)
+TS_TEST(test_comparing)
 {
-    tai_t *tm;
+    tai_rc_t rv;
+    tai_t *tm1, *tm2;
+    int i;
+    struct {
+        char *date1;
+        char *date2;
+        int   op;
+        int   exp;
+    } table[] = {
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:31 +0200", TAI_OP_NE, TAI_OK    }, /* 00 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:30 +0200", TAI_OP_NE, TAI_FALSE }, /* 01 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:30 +0200", TAI_OP_EQ, TAI_OK    }, /* 02 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:31 +0200", TAI_OP_EQ, TAI_FALSE }, /* 03 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:20 +0200", TAI_OP_LT, TAI_OK    }, /* 04 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:30 +0200", TAI_OP_LT, TAI_FALSE }, /* 05 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:20 +0200", TAI_OP_LE, TAI_OK    }, /* 06 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:30 +0200", TAI_OP_LE, TAI_OK    }, /* 07 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:31 +0200", TAI_OP_LE, TAI_FALSE }, /* 08 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:31 +0200", TAI_OP_GT, TAI_OK    }, /* 09 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:30 +0200", TAI_OP_GT, TAI_FALSE }, /* 10 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:31 +0200", TAI_OP_GE, TAI_OK    }, /* 11 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:30 +0200", TAI_OP_GE, TAI_OK    }, /* 12 */
+        { "2000-02-22 10:20:30 +0200", "2000-02-22 10:20:20 +0200", TAI_OP_GE, TAI_FALSE }, /* 13 */
+        { NULL, NULL, 0, 0 }
+    };
 
-    ts_test_check(TS_CTX, "time formatting");
-    tai_create(&tm);
-    /* FIXME */
-    tai_destroy(tm);
+    tai_create(&tm1);
+    tai_create(&tm2);
+    ts_test_check(TS_CTX, "time comparing");
+    for (i = 0; table[i].date1 != NULL; i++) {
+        ts_test_log(TS_CTX, "date1=%s, date2=%s, op=%d", table[i].date1, table[i].date2, table[i].op);
+        tai_parse(tm1, table[i].date1, strlen(table[i].date1), "%Y-%m-%d %H:%M:%S %z");
+        tai_parse(tm2, table[i].date2, strlen(table[i].date2), "%Y-%m-%d %H:%M:%S %z");
+        if ((rv = tai_op(tm1, table[i].op, tm2)) != table[i].exp)
+            ts_test_fail(TS_CTX, "#%d: output \"%d\", expected \"%d\"", i, rv, table[i].exp);
+    }
+    tai_destroy(tm2);
+    tai_destroy(tm1);
 }
 
 int main(int argc, char *argv[])
@@ -143,7 +175,7 @@
     ts_suite_test(ts, test_object,       "object handling");
     ts_suite_test(ts, test_importexport, "time import/export");
     ts_suite_test(ts, test_parsing,      "time parsing");
-    ts_suite_test(ts, test_formatting,   "time formatting");
+    ts_suite_test(ts, test_comparing,    "time comparing");
     n = ts_suite_run(ts);
     ts_suite_free(ts);
     return n;

CVSTrac 2.0.1