From: Robert Kessl Date: Mon, 7 Jul 2014 08:31:37 +0000 (+0200) Subject: tableprinter: update of tests X-Git-Tag: v6.1~3^2~115 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=db2e817025638b9738e5ff8f8f5ccc1fbf68a2f3;p=libucw.git tableprinter: update of tests --- diff --git a/ucw/table-test-2.c b/ucw/table-test-2.c index e4f45bb2..f46427c0 100644 --- a/ucw/table-test-2.c +++ b/ucw/table-test-2.c @@ -16,7 +16,7 @@ enum test_table_cols { static struct table test_tbl = { TBL_COLUMNS { - [TEST_COL0_SIZE] = TBL_COL_SIZE_FMT("size", 10, UNIT_BYTE), + [TEST_COL0_SIZE] = TBL_COL_SIZE_FMT("size", 15, UNIT_BYTE), [TEST_COL1_TS] = TBL_COL_TIMESTAMP("ts", 20), TBL_COL_END }, @@ -66,9 +66,58 @@ static void do_test(void) bclose(out); } + + +static struct table test_tbl2 = { + TBL_COLUMNS { + [TEST_COL0_SIZE] = TBL_COL_SIZE_FMT("size", 15, UNIT_BYTE), + [TEST_COL1_TS] = TBL_COL_TIMESTAMP("ts", 20), + TBL_COL_END + }, + TBL_OUTPUT_HUMAN_READABLE, +}; + +static void do_test2(void) +{ + struct fastbuf *out; + out = bfdopen_shared(1, 4096); + table_init(&test_tbl2); + table_set_col_order_by_name(&test_tbl2, ""); + const char *err = table_set_option_value(&test_tbl2, "cols", "size[kb],size[mb],size[gb],size[tb],ts[datetime],ts[timestamp]"); + if(err) { + opt_failure("err in table_set_option_value: '%s'.", err); + abort(); + } + table_start(&test_tbl2, out); + + u64 test_time = 1403685533; + s64 test_size = 4LU*(1024LU * 1024LU * 1024LU); + + table_col_size(&test_tbl2, TEST_COL0_SIZE, test_size); + table_col_timestamp(&test_tbl2, TEST_COL1_TS, test_time); + table_end_row(&test_tbl2); + + table_col_size(&test_tbl2, TEST_COL0_SIZE, test_size); + table_col_timestamp(&test_tbl2, TEST_COL1_TS, test_time); + table_end_row(&test_tbl2); + + test_size = test_size * 1024LU; + + table_col_size(&test_tbl2, TEST_COL0_SIZE, test_size); + table_col_timestamp(&test_tbl2, TEST_COL1_TS, test_time); + table_end_row(&test_tbl2); + + table_end(&test_tbl2); + table_cleanup(&test_tbl2); + + bclose(out); +} + int main(int argc UNUSED, char **argv UNUSED) { do_test(); + do_test2(); + return 0; } diff --git a/ucw/table-test-2.t b/ucw/table-test-2.t index 92874dc9..649621cb 100644 --- a/ucw/table-test-2.t +++ b/ucw/table-test-2.t @@ -1,9 +1,13 @@ Run: ../obj/ucw/table-test-2 Out <