[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 38c0017 3/3: Add some unit tests for present
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 38c0017 3/3: Add some unit tests for present behavior that doesn't seem ideal |
Date: |
Wed, 15 Aug 2018 18:16:13 -0400 (EDT) |
branch: master
commit 38c0017386527a2bacce92ec857c0d5c03466d45
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Add some unit tests for present behavior that doesn't seem ideal
---
report_table_test.cpp | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/report_table_test.cpp b/report_table_test.cpp
index e722148..a9ac690 100644
--- a/report_table_test.cpp
+++ b/report_table_test.cpp
@@ -142,6 +142,47 @@ void report_table_test::test_generally()
set_column_widths(99, 1, v);
BOOST_TEST(widths(v) == expected);
+ // Same columns, but inadequate page width.
+
+ // PDF !! Begin section subject to revision.
+
+ // Tests in this section are overconstrained in that they don't
+ // have enough room to print all inelastic columns with bilateral
+ // margins of at least one point.
+ //
+ // For now, what's tested is the actual behavior of current code
+ // in the absence of elastic columns, viz.:
+ // - for vector input column widths W[i], speculatively define
+ // X[i] = W[i] + input margin (a positive scalar)
+ // - if sum(X) < available page width
+ // then set W=X
+ // - if sum(W) < available page width < sum(X)
+ // then apportion any available margin among columns in W
+ // and issue no diagnostic even if some columns get no margin
+ // - else, i.e., if available page width < sum(W) < sum(X)
+ // then set W=X
+ // and issue a diagnostic
+
+ std::vector<int> actual;
+
+ v = bloat({1, 2, 3}, {0, 0, 0});
+ set_column_widths(11, 1, v);
+ actual = {3, 4, 4};
+ BOOST_TEST(widths(v) == actual);
+
+ v = bloat({1, 2, 3}, {0, 0, 0});
+ set_column_widths( 6, 1, v);
+ actual = {1, 2, 3};
+ BOOST_TEST(widths(v) == actual);
+
+ // Warning given here:
+ v = bloat({1, 2, 3}, {0, 0, 0});
+ set_column_widths( 5, 1, v);
+ actual = {3, 4, 5};
+ BOOST_TEST(widths(v) == actual);
+
+ // PDF !! End section subject to revision.
+
// An elastic column occupies all available space not claimed by
// inelastic columns...
v = bloat({1, 2, 0, 3}, {0, 0, 1, 0});