diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-07-12 14:20:09 +0900 |
---|---|---|
committer | Sven Eden <sven.eden@prydeworx.com> | 2018-10-29 10:18:23 +0100 |
commit | eb4f4389f413d50ea322975c706b270b5f8c8bed (patch) | |
tree | e13ed541695ea36b682154e568040ac5e3cc212b | |
parent | 4f2ae5c006b0e0d8ac1533b423a41c9cab504259 (diff) |
test: add a reproducer of issue #9549
(cherry picked from commit a6e964712c53b877543cf18aff59ae99cffc1f50)
-rw-r--r-- | src/test/test-format-table.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/test-format-table.c b/src/test/test-format-table.c index adcc41416..2527cacbb 100644 --- a/src/test/test-format-table.c +++ b/src/test/test-format-table.c @@ -5,6 +5,30 @@ #include "string-util.h" #include "time-util.h" +static void test_issue_9549(void) { + _cleanup_(table_unrefp) Table *table = NULL; + _cleanup_free_ char *formatted = NULL; + + assert_se(table = table_new("NAME", "TYPE", "RO", "USAGE", "CREATED", "MODIFIED")); + assert_se(table_set_align_percent(table, TABLE_HEADER_CELL(3), 100) >= 0); + assert_se(table_add_many(table, + TABLE_STRING, "foooo", + TABLE_STRING, "raw", + TABLE_BOOLEAN, false, + TABLE_SIZE, (uint64_t) (673.7*1024*1024), + TABLE_STRING, "Wed 2018-07-11 00:10:33 JST", + TABLE_STRING, "Wed 2018-07-11 00:16:00 JST") >= 0); + + table_set_width(table, 75); + assert_se(table_format(table, &formatted) >= 0); + + printf("%s\n", formatted); + assert_se(streq(formatted, + "NAME TYPE RO USAGE CREATED MODIFIED \n" + "foooo raw no 673.6M Wed 2018-07-11 00:10:33 J… Wed 2018-07-11 00:16:00 JST\n" + )); +} + int main(int argc, char *argv[]) { _cleanup_(table_unrefp) Table *t = NULL; @@ -135,5 +159,7 @@ int main(int argc, char *argv[]) { " yes xxx yes xxx xxx \n" "5min 5min \n")); + test_issue_9549(); + return 0; } |