[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 8c1e124 2/9: Add simple unit test for get_nee
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 8c1e124 2/9: Add simple unit test for get_needed_pages_count() |
Date: |
Fri, 9 Feb 2018 17:39:15 -0500 (EST) |
branch: master
commit 8c1e1241da0893963567bbc487044523c3224c6c
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Add simple unit test for get_needed_pages_count()
Verify that the function returns expected results. including for the
edge cases.
---
miscellany_test.cpp | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index e55436c..f5890ac 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -236,6 +236,25 @@ void test_trimming()
BOOST_TEST_EQUAL(s, "a ; a");
}
+void test_get_needed_pages_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 get_needed_pages_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();
@@ -243,6 +262,7 @@ int test_main(int, char*[])
test_minmax();
test_prefix_and_suffix();
test_trimming();
+ test_get_needed_pages_count();
return 0;
}
- [lmi-commits] [lmi] master updated (246f754 -> 76bcb28), Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 2c2145d 3/9: Fix closing brace indentation in wx_table_generator.cpp, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 4b75c18 5/9: Add a comment explaining why column_info::width_ is not const, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 11da7b5 1/9: Extract get_needed_pages_count() from PDF generation code, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 58c87b5 7/9: Make column_info::is_variable_width_ field private, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 76bcb28 9/9: Avoid passing an enum by const value, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master ce0f83e 8/9: Clip variable-width columns in wx_table_generator, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 8c1e124 2/9: Add simple unit test for get_needed_pages_count(),
Greg Chicares <=
- [lmi-commits] [lmi] master 79144a7 4/9: Make unchangeable wx_table_generator::column_info fields const, Greg Chicares, 2018/02/09
- [lmi-commits] [lmi] master 2b0c1fd 6/9: Replace column_info::is_centered_ with is_centered(), Greg Chicares, 2018/02/09