From bcccb399f05d8b2cf90a1df330cb0a4b032ae8c8 Mon Sep 17 00:00:00 2001 From: Robert Kessl Date: Wed, 2 Jul 2014 16:00:17 +0200 Subject: [PATCH] tableprinter: update of tests --- ucw/table-test-align.c | 3 --- ucw/table-test.c | 14 ++++++++++++-- ucw/table-test.t | 6 +++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ucw/table-test-align.c b/ucw/table-test-align.c index 4df4292e..f0ddfaf0 100644 --- a/ucw/table-test-align.c +++ b/ucw/table-test-align.c @@ -102,9 +102,6 @@ int main(int argc UNUSED, char **argv) table_init(&test_tbl); process_command_line_opts(argv, &test_tbl); - //bprintf(out, "width: %X; masked: %d; mask: %X\n", test_tbl.columns[0].width, test_tbl.columns[0].width & CELL_ALIGN_MASK, CELL_ALIGN_MASK); - //bflush(out); - print_table(&test_tbl, out); table_cleanup(&test_tbl); bclose(out); diff --git a/ucw/table-test.c b/ucw/table-test.c index b90b6932..b9d1bfe5 100644 --- a/ucw/table-test.c +++ b/ucw/table-test.c @@ -6,11 +6,12 @@ #include #include +#include #include #include enum test_table_cols { - test_col0_str, test_col1_int, test_col2_uint, test_col3_bool, test_col4_double + test_col0_str, test_col1_int, test_col2_uint, test_col3_bool, test_col4_double, test_col5_size, test_col6_time }; static struct table_col_info test_column_order[] = { TBL_COL(test_col3_bool), TBL_COL(test_col4_double), TBL_COL(test_col2_uint), TBL_COL(test_col1_int), TBL_COL(test_col0_str) }; @@ -22,6 +23,8 @@ static struct table test_tbl = { [test_col2_uint] = TBL_COL_UINT("col2_uint", 9), [test_col3_bool] = TBL_COL_BOOL("col3_bool", 9), [test_col4_double] = TBL_COL_DOUBLE("col4_double", 11, 2), + [test_col5_size] = TBL_COL_SIZE("col5_size", 11), + [test_col6_time] = TBL_COL_TIMESTAMP("col6_timestamp", 20), TBL_COL_END }, TBL_COL_ORDER(test_column_order), @@ -76,6 +79,8 @@ static void do_print1(struct table *test_tbl) table_col_printf(test_tbl, test_col2_uint, "XXX-%u", 22222); table_col_bool(test_tbl, test_col3_bool, 1); table_col_double(test_tbl, test_col4_double, 1.5); + table_col_size(test_tbl, test_col5_size, (1024LU*1024LU*1024LU*5LU)); + table_col_timestamp(test_tbl, test_col6_time, 1404305876); table_end_row(test_tbl); table_col_str(test_tbl, test_col0_str, "test"); @@ -83,6 +88,8 @@ static void do_print1(struct table *test_tbl) table_col_uint(test_tbl, test_col2_uint, 100); table_col_bool(test_tbl, test_col3_bool, 0); table_col_double(test_tbl, test_col4_double, 1.5); + table_col_size(test_tbl, test_col5_size, (1024LU*1024LU*1024LU*2LU)); + table_col_timestamp(test_tbl, test_col6_time, 1404305909); table_end_row(test_tbl); } @@ -112,7 +119,10 @@ static void process_command_line_opts(char *argv[], struct table *tbl) GARY_INIT(cli_table_opts, 0); opt_parse(&table_printer_opts, argv+1); - table_set_gary_options(tbl, cli_table_opts); + const char *err = table_set_gary_options(tbl, cli_table_opts); + if(err) { + opt_failure("error while setting cmd line options: %s", err); + } GARY_FREE(cli_table_opts); } diff --git a/ucw/table-test.t b/ucw/table-test.t index e7901788..710c37ed 100644 --- a/ucw/table-test.t +++ b/ucw/table-test.t @@ -71,18 +71,22 @@ col1_int: 10000 col2_uint: XXX-22222 col3_bool: true col4_double: 1.50 +col5_size: 5368709120 +col6_timestamp: 1404305876 col0_str: test col1_int: -100 col2_uint: 100 col3_bool: false col4_double: 1.50 +col5_size: 2147483648 +col6_timestamp: 1404305909 EOF Run: ../obj/ucw/table-test -n Out <