/*
- * 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>
u64 result;
const char *parse_err = xt_size.parse(size_strs[i], &result, pool);
- ASSERT_MSG(parse_err == NULL, "Unexpected error in xt_size.parse");
- ASSERT_MSG(size_parsed[i] == result, "xt_size.parse parsed an incorrect value.");
+ if(parse_err != NULL) {
+ die("Unexpected error in xt_size.parse");
+ }
+ if(size_parsed[i] != result) {
+ die("xt_size.parse parsed an incorrect value.");
+ }
- const char *result_str = xt_size.format(&result, i | SIZE_UNITS_FIXED, pool);
+ const char *result_str = xt_size.format(&result, XT_SIZE_FMT_UNIT(i), pool);
bprintf(out, "%s %s\n", size_strs[i], result_str);
i++;
static const char *size_strs[] = {
"1X",
"KB",
+ "X1KB",
+ "1XKB",
+ "1KBX",
"\0",
NULL
};
while(bool_strs[i] != NULL) {
bool result;
const char *err_str = xt_bool.parse(bool_strs[i], &result, pool);
- ASSERT_MSG(err_str == NULL, "Unexpected error in xt_bool.parse %s", err_str);
- ASSERT_MSG(bool_parsed[i] == result, "xt_bool.parse parsed an incorrect value.");
+ if(err_str != NULL) {
+ die("Unexpected error in xt_bool.parse %s", err_str);
+ }
+ if(bool_parsed[i] != result) {
+ die("xt_bool.parse parsed an incorrect value.");
+ }
bprintf(out, "%s %s\n", bool_strs[i], result ? "true" : "false");
i++;
}
while(timestamp_strs[i]) {
u64 result;
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);
+ if(err_str != NULL) {
+ die("Unexpected error in xt_timestamp.parse: %s", err_str);
+ }
+ if(timestamp_parsed[i] != result) {
+ die("Expected: %" PRIu64 " but got %" PRIu64, timestamp_parsed[i], result);
+ }
+
bprintf(out, "%" PRIu64 " %" PRIu64 "\n", timestamp_parsed[i], result);
i++;
"1403685533X",
"2014X-06-25 08:38:53",
"2X014-06-25 08:38:53",
+ "2014-06-25 08:38:53X",
+ "X2014-06-25 08:38:53",
"X1403685533",
+ "14X03685533",
+ "1403685533X",
NULL
};
bprintf(out, "xt_timestamp.parse error: '%s'.\n", err_str);
}
- // ASSERT_MSG(err_str != NULL,
- //bprintf(out, "%" PRIu64 " %" PRIu64 "\n", timestamp_parsed[i], result);
- //ASSERT_MSG(timestamp_parsed[i] == result, "Expected: %" PRIu64 " but got %" PRIu64, timestamp_parsed[i], result);
-
i++;
}