lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 0cef4eb 3/3: Demonstrate terser syntax in uni


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 0cef4eb 3/3: Demonstrate terser syntax in unit test
Date: Sun, 12 Aug 2018 09:55:53 -0400 (EDT)

branch: master
commit 0cef4ebf5fb8334a421f221bbd3d6d46eb5f6a16
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Demonstrate terser syntax in unit test
---
 report_table_test.cpp | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/report_table_test.cpp b/report_table_test.cpp
index 8c1cbab..2e98235 100644
--- a/report_table_test.cpp
+++ b/report_table_test.cpp
@@ -103,23 +103,32 @@ class report_table_test
 
 void report_table_test::test_bloat()
 {
-    std::vector<int>  w = {3, 1, 0, 0, 2};
-    std::vector<bool> e = {0, 1, 0, 1, 0};
-    std::vector<table_column_info> v =
+    std::vector<table_column_info> const v =
         {{"",  3, oe_right, oe_inelastic}
         ,{"",  1, oe_right, oe_elastic  }
         ,{"",  0, oe_right, oe_inelastic}
         ,{"",  0, oe_right, oe_elastic  }
         ,{"",  2, oe_right, oe_inelastic}
         };
-    BOOST_TEST(bloat(w, e) == v);
+
+    std::vector<int>  const w = {3, 1, 0, 0, 2};
+    std::vector<bool> const e = {0, 1, 0, 1, 0};
+    BOOST_TEST(v == bloat(w, e));
+
+    // Progressively terser equivalents.
+
+    std::vector<table_column_info> x = bloat({3, 1, 0, 0, 2}, {0, 1, 0, 1, 0});
+    BOOST_TEST(v == x);
+
+    auto const y = bloat({3, 1, 0, 0, 2}, {0, 1, 0, 1, 0});
+    BOOST_TEST(v == y);
+
+    BOOST_TEST(v == bloat({3, 1, 0, 0, 2}, {0, 1, 0, 1, 0}));
 }
 
 void report_table_test::test_generally()
 {
-    std::vector<int>  w = {1, 2, 3};
-    std::vector<bool> e = {0, 0, 0};
-    std::vector<table_column_info> v = bloat(w, e);
+    std::vector<table_column_info> v = bloat({1, 2, 3}, {0, 0, 0});
     set_column_widths(13, 1, v);
     std::vector<int> const observed = widths(v);
     std::vector<int> const expected = {3, 4, 5};



reply via email to

[Prev in Thread] Current Thread [Next in Thread]