[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 502fedc 01/10: Improve [lr]trim unit test and
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 502fedc 01/10: Improve [lr]trim unit test and documentation |
Date: |
Mon, 6 Feb 2017 04:10:55 +0000 (UTC) |
branch: master
commit 502fedcb22fbceb4487bf68d7607310196df7074
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Improve [lr]trim unit test and documentation
Added separate tests for ltrim() and rtrim(), and arguably redundant but
cheap tests to show that applying them both to an already-trimmed string
does nothing.
The motivation was not so much to prove that these two functions work
correctly as to provide simple examples for copying and pasting. The
best documentation of a function is a "behold" comment on its unit test:
unlike prose, it's demonstrably correct.
---
miscellany_test.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index 367545a..5516988 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -224,11 +224,15 @@ void test_trimming()
BOOST_TEST_EQUAL(s, "a");
s = "a; ;";
- ltrim(s, superfluous); rtrim(s, superfluous);
+ rtrim(s, superfluous); // Shows what rtrim() does.
+ BOOST_TEST_EQUAL(s, "a");
+ ltrim(s, superfluous); rtrim(s, superfluous); // Does nothing, correctly.
BOOST_TEST_EQUAL(s, "a");
s = "; ;a";
- ltrim(s, superfluous); rtrim(s, superfluous);
+ ltrim(s, superfluous); // Shows what ltrim() does.
+ BOOST_TEST_EQUAL(s, "a");
+ ltrim(s, superfluous); rtrim(s, superfluous); // Does nothing, correctly.
BOOST_TEST_EQUAL(s, "a");
}
- [lmi-commits] [lmi] master updated (97d2acd -> 6eb2614), Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master 934e2f6 04/10: Emphasize that [lr]trim() removes no internal superfluity, Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master 3e089d5 03/10: Fix defect introduced 20110801T2357Z: arguments omitted, Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master e52e02c 02/10: GUI sequence parser diagnostics: generalize code, improve documentation, Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master 987adcc 06/10: Get sequence parser diagnostics from exception, not function, Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master 6eb2614 10/10: Improve unit test, Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master 601f252 07/10: Throw any parser diagnostics from interval_representation(), Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master aee673f 05/10: Fix defect introduced 20170205T2107Z: fixed the wrong problem, Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master e411ac4 09/10: Throw any parser errors from all *_representation() functions, Greg Chicares, 2017/02/05
- [lmi-commits] [lmi] master 502fedc 01/10: Improve [lr]trim unit test and documentation,
Greg Chicares <=
- [lmi-commits] [lmi] master 4f05707 08/10: Omit unhelpful file name and line number from a warning, Greg Chicares, 2017/02/05