lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master e49df2c 5/7: Alphabetize unit-test functions


From: Greg Chicares
Subject: [lmi-commits] [lmi] master e49df2c 5/7: Alphabetize unit-test functions
Date: Mon, 12 Feb 2018 07:15:10 -0500 (EST)

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

    Alphabetize unit-test functions
    
    Also made the alphabetization of functions in the corresponding header
    microscopically less woeful than it has become over the years.
---
 miscellany.hpp      | 22 +++++++++++-----------
 miscellany_test.cpp | 40 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/miscellany.hpp b/miscellany.hpp
index a42ac74..89082fe 100644
--- a/miscellany.hpp
+++ b/miscellany.hpp
@@ -189,6 +189,17 @@ inline unsigned char lmi_toupper(unsigned char c)
     return static_cast<unsigned char>(std::toupper(c));
 }
 
+/// Compute the number of pages needed to display the given number of non-blank
+/// rows in groups of the specified size separated by blank rows.
+///
+/// Preconditions: 0 < total_rows && 0 < rows_per_group <= rows_per_page
+
+int LMI_SO page_count
+    (int total_rows
+    ,int rows_per_page
+    ,int rows_per_group
+    );
+
 /// DWISOTT
 ///
 /// Perhaps this function template's only legitimate use is within a
@@ -213,16 +224,5 @@ inline void stifle_warning_for_unused_value(T const& t)
     (void)&t;
 }
 
-/// Compute the number of pages needed to display the given number of non-blank
-/// rows in groups of the specified size separated by blank rows.
-///
-/// Preconditions: 0 < total_rows && 0 < rows_per_group <= rows_per_page
-
-int LMI_SO page_count
-    (int total_rows
-    ,int rows_per_page
-    ,int rows_per_group
-    );
-
 #endif // miscellany_hpp
 
diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index 673277a..a62648e 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -151,6 +151,25 @@ void test_minmax()
     BOOST_TEST(!(zero <  m || m <  one));
 }
 
+void test_page_count()
+{
+    // Fix the number of rows per page and per group, we can reasonably suppose
+    // that nothing critically depends on their precise values and all the
+    // logic of this function will be tested by just trying the different
+    // numbers of total rows.
+    auto const do_test = [](int total_rows) -> int
+        {
+        return page_count(total_rows, 28, 5);
+        };
+
+    BOOST_TEST_EQUAL(do_test( 1), 1); // Edge case (0 rows is not allowed).
+    BOOST_TEST_EQUAL(do_test(17), 1); // Just a trivial sanity test.
+    BOOST_TEST_EQUAL(do_test(24), 1); // 4 full groups + incomplete last group.
+    BOOST_TEST_EQUAL(do_test(25), 2); // 5 full groups don't fit on one page.
+    BOOST_TEST_EQUAL(do_test(44), 2); // 4 + 4 groups + incomplete last one.
+    BOOST_TEST_EQUAL(do_test(45), 3); // 9 full groups don't fit on two pages.
+}
+
 void test_prefix_and_suffix()
 {
     std::string s = "";
@@ -236,33 +255,14 @@ void test_trimming()
     BOOST_TEST_EQUAL(s, "a ; a");
 }
 
-void test_page_count()
-{
-    // Fix the number of rows per page and per group, we can reasonably suppose
-    // that nothing critically depends on their precise values and all the
-    // logic of this function will be tested by just trying the different
-    // numbers of total rows.
-    auto const do_test = [](int total_rows) -> int
-        {
-        return page_count(total_rows, 28, 5);
-        };
-
-    BOOST_TEST_EQUAL(do_test( 1), 1); // Edge case (0 rows is not allowed).
-    BOOST_TEST_EQUAL(do_test(17), 1); // Just a trivial sanity test.
-    BOOST_TEST_EQUAL(do_test(24), 1); // 4 full groups + incomplete last group.
-    BOOST_TEST_EQUAL(do_test(25), 2); // 5 full groups don't fit on one page.
-    BOOST_TEST_EQUAL(do_test(44), 2); // 4 + 4 groups + incomplete last one.
-    BOOST_TEST_EQUAL(do_test(45), 3); // 9 full groups don't fit on two pages.
-}
-
 int test_main(int, char*[])
 {
     test_each_equal();
     test_files_are_identical();
     test_minmax();
+    test_page_count();
     test_prefix_and_suffix();
     test_trimming();
-    test_page_count();
 
     return 0;
 }



reply via email to

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