[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master d54979e 2/3: Augment unit test
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master d54979e 2/3: Augment unit test |
Date: |
Wed, 15 Aug 2018 18:16:13 -0400 (EDT) |
branch: master
commit d54979e8a287b5b2aa4c1a92ad5a79749457ca19
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Augment unit test
---
report_table_test.cpp | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/report_table_test.cpp b/report_table_test.cpp
index 5b2b20c..e722148 100644
--- a/report_table_test.cpp
+++ b/report_table_test.cpp
@@ -128,9 +128,39 @@ void report_table_test::test_bloat()
void report_table_test::test_generally()
{
- std::vector<table_column_info> v = bloat({1, 2, 3}, {0, 0, 0});
- set_column_widths(13, 1, v);
- std::vector<int> const expected = {3, 4, 5};
+ std::vector<table_column_info> v;
+ std::vector<int> expected;
+
+ // Width with default margins (12) = maximum available page width.
+ v = bloat({1, 2, 3}, {0, 0, 0});
+ set_column_widths(12, 1, v);
+ expected = {3, 4, 5};
+ BOOST_TEST(widths(v) == expected);
+
+ // Same columns: same layout, even if page is much wider (99).
+ v = bloat({1, 2, 3}, {0, 0, 0});
+ set_column_widths(99, 1, v);
+ BOOST_TEST(widths(v) == expected);
+
+ // An elastic column occupies all available space not claimed by
+ // inelastic columns...
+ v = bloat({1, 2, 0, 3}, {0, 0, 1, 0});
+ set_column_widths(99, 1, v);
+ expected = {3, 4, (99-12), 5};
+ BOOST_TEST(widths(v) == expected);
+ // ...though its width might happen to be zero (PDF !! but see
+ // https://lists.nongnu.org/archive/html/lmi/2018-07/msg00049.html
+ // which questions whether zero should be allowed):
+ v = bloat({1, 2, 0, 3}, {0, 0, 1, 0});
+ set_column_widths(12, 1, v);
+ expected = {3, 4, 0, 5};
+ BOOST_TEST(widths(v) == expected);
+
+ // Multiple elastic columns apportion all unclaimed space among
+ // themselves.
+ v = bloat({1, 2, 0, 3}, {1, 0, 1, 0});
+ set_column_widths(99, 1, v);
+ expected = {45, 4, 45, 5};
BOOST_TEST(widths(v) == expected);
}