test-date: use new assertion macros
This commit is contained in:
@@ -12,17 +12,17 @@ static void test_should_pass(const char *p) {
|
||||
char buf[FORMAT_TIMESTAMP_MAX], buf_relative[FORMAT_TIMESTAMP_RELATIVE_MAX];
|
||||
|
||||
log_info("Test: %s", p);
|
||||
assert_se(parse_timestamp(p, &t) >= 0);
|
||||
assert_se(format_timestamp_style(buf, sizeof(buf), t, TIMESTAMP_US));
|
||||
ASSERT_OK(parse_timestamp(p, &t));
|
||||
ASSERT_NOT_NULL(format_timestamp_style(buf, sizeof(buf), t, TIMESTAMP_US));
|
||||
log_info("\"%s\" → \"%s\"", p, buf);
|
||||
|
||||
assert_se(parse_timestamp(buf, &q) >= 0);
|
||||
ASSERT_OK(parse_timestamp(buf, &q));
|
||||
if (q != t)
|
||||
log_error("round-trip failed: \"%s\" → \"%s\"",
|
||||
buf, FORMAT_TIMESTAMP_STYLE(q, TIMESTAMP_US));
|
||||
assert_se(q == t);
|
||||
ASSERT_EQ(q, t);
|
||||
|
||||
assert_se(format_timestamp_relative(buf_relative, sizeof(buf_relative), t));
|
||||
ASSERT_NOT_NULL(format_timestamp_relative(buf_relative, sizeof(buf_relative), t));
|
||||
log_info("%s", strna(buf_relative));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ static void test_should_parse(const char *p) {
|
||||
usec_t t;
|
||||
|
||||
log_info("Test: %s", p);
|
||||
assert_se(parse_timestamp(p, &t) >= 0);
|
||||
ASSERT_OK(parse_timestamp(p, &t));
|
||||
log_info("\"%s\" → \"@%" PRI_USEC "\"", p, t);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ static void test_should_fail(const char *p) {
|
||||
log_info("\"%s\" → \"@%" PRI_USEC "\" (unexpected)", p, t);
|
||||
else
|
||||
log_info("parse_timestamp() returns %d (expected)", r);
|
||||
assert_se(r < 0);
|
||||
ASSERT_ERROR(r);
|
||||
}
|
||||
|
||||
static void test_one(const char *p) {
|
||||
@@ -65,7 +65,7 @@ static void test_one_noutc(const char *p) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/* Tests have hard-coded results that do not expect a specific timezone to be set by the caller */
|
||||
assert_se(unsetenv("TZ") >= 0);
|
||||
ASSERT_OK_ERRNO(unsetenv("TZ"));
|
||||
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user