[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 59797a5 9/9: Make unit tests pastable into GU
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 59797a5 9/9: Make unit tests pastable into GUI |
Date: |
Wed, 15 Feb 2017 20:27:00 -0500 (EST) |
branch: master
commit 59797a55df25b939611893abfea29a2450226c47
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Make unit tests pastable into GUI
Pasting the text between scissors lines into the GUI, thus:
File | New | Census
Census | Paste census
permits exploring differences between class InputSequence and the GUI
sequence editor. Generally, the GUI editor is more strict. Sequences
that it refuses to edit are marked in the "Comments" column. Invalid
sequences are omitted because they cannot even be pasted.
---
input_sequence_test.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/input_sequence_test.cpp b/input_sequence_test.cpp
index e35a3c0..d7d62ce 100644
--- a/input_sequence_test.cpp
+++ b/input_sequence_test.cpp
@@ -91,8 +91,7 @@ void check
#if defined TEST_REPRESENTATION
INVOKE_BOOST_TEST(bv && bs && bf, file, line);
#else // !defined TEST_REPRESENTATION
- // For the nonce, each 'g' is just a copy of its corresponding 'e',
- // so don't make 'bf' fail the test yet.
+ // Don't make 'bf' fail the test yet.
INVOKE_BOOST_TEST(bv && bs /* && bf */, file, line);
#endif // !defined TEST_REPRESENTATION
}
@@ -122,6 +121,8 @@ void check
int test_main(int, char*[])
{
+ std::string census =
"\nCorporationPayment\tCorporationPaymentMode\tComments\n";
+
using strvec = std::vector<std::string>;
// Arguments to check():
@@ -147,6 +148,7 @@ int test_main(int, char*[])
int const n = 5;
double const d[n] = {0, 0, 0, 0, 0};
std::string const e("");
+ census += e + "\t\tcorp pmt empty\t\n";
std::string const g("0");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -156,6 +158,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
std::string const e(" ");
+ census += e + "\t\tcorp pmt blank\t\n";
std::string const g("0");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -166,6 +169,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {1, 1, 1, 7, 7, 0, 0, 0, 0};
std::string const e("1 3; 7 5;0");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 3); 7 [3, 5); 0 [5, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -176,6 +180,7 @@ int test_main(int, char*[])
int const n = 5;
double const d[n] = {1, 2, 3, 3, 3};
std::string const e("1; 2; 3");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 1); 2 [1, 2); 3 [2, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -185,6 +190,7 @@ int test_main(int, char*[])
int const n = 10;
double const d[n] = {1, 1, 1, 3, 3, 3, 5, 5, 5, 7};
std::string const e("1 3; 3 6; 5 9; 7");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 3); 3 [3, 6); 5 [6, 9); 7 [9, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -194,6 +200,7 @@ int test_main(int, char*[])
int const n = 10;
double const d[n] = {1, 1, 1, 3, 3, 3, 5, 5, 5, 7};
std::string const e("1 @93; 3 @96; 5 @99; 7");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, @93); 3 address@hidden, @96); 5 address@hidden,
@99); 7 address@hidden, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -203,6 +210,7 @@ int test_main(int, char*[])
int const n = 10;
double const d[n] = {1, 1, 1, 3, 3, 3, 5, 5, 5, 7};
std::string const e("1 #3; 3 #3; 5 #3; 7");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 3); 3 [3, 6); 5 [6, 9); 7 [9, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -214,6 +222,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {1, 1, 3, 3, 3, 5, 7, 7, 7};
std::string const e("1 [0, 2); 3 [2, 5); 5 [5, 6); 7");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 2); 3 [2, 5); 5 [5, 6); 7 [6, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -223,6 +232,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {1, 1, 1, 3, 3, 3, 5, 7, 7};
std::string const e("1; 1 (0, 2]; 3 (2, 5]; 5 (5, 6]; 7");
+ census += e + "\t\t\t\n";
// Should the first two intervals be combined?
std::string const g("1 [0, 1); 1 [1, 3); 3 [3, 6); 5 [6, 7); 7 [7,
maturity)");
check(__FILE__, __LINE__, n, d, e, g);
@@ -233,6 +243,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {1, 1, 1, 1, 2, 3, 4, 5, 5};
std::string const e("1 [0, 4); 2 5; 3 #1; 4 @97; 5");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 4); 2 [4, 5); 3 [5, 6); 4 [6, @97); 5
address@hidden, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -242,6 +253,7 @@ int test_main(int, char*[])
int const n = 5;
double const d[n] = {1, 3, 5, 7, 7};
std::string const e("1 [0, 1); 3 [1, 2); 5 (1, 2]; 7");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 1); 3 [1, 2); 5 [2, 3); 7 [3, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -251,6 +263,7 @@ int test_main(int, char*[])
int const n = 5;
double const d[n] = {1, 3, 5, 7, 7};
std::string const e("1 [0, 1); 3 [1, 1]; 5 (1, 2]; 7");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, 1); 3 [1, 2); 5 [2, 3); 7 [3, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -260,6 +273,7 @@ int test_main(int, char*[])
int const n = 5;
double const d[n] = {0, 0, 0, 0, 0};
std::string const e("1 [0, 0); 3 (1, 2); 5 (2, 2]; 7");
+// census += "'" + e + "\t\timproper first interval\t\n";
std::string const g(""); // Expression is invalid.
char const* m =
"Interval [ 0, 0 ) is improper: it ends before it begins."
@@ -281,6 +295,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
std::string const e("1; 9 (2, 0]; 3 [7, 3); 5 (5, 5); 7");
+ // census: invalid expression cannot be pasted into GUI
std::string const g(""); // Expression is invalid.
char const* m =
"Interval [ 3, 1 ) is improper: it ends before it begins."
@@ -303,6 +318,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {0, 1, 0, 3, 0, 5, 7, 7, 7};
std::string const e("1 [1, 2); 3 [3, 3]; 5 (4, 5]; 7");
+ census += e + "\t\t! not a partition\t\n";
std::string const g("0 [0, 1); 1 [1, 2); 0 [2, 3); 3 [3, 4); 0 [4, 5); 5
[5, 6); 7 [6, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -312,6 +328,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {0, 1, 1, 3, 3, 5, 5, 7, 7};
std::string const e("0; 1 (0, 8]; 3 (2, 7]; 5 (4, 6]; 7");
+ census += e + "\t\t! not a partition\t\n";
// mathematical_representation() returns '...1 [1, maturity)3 [3, 8)...'?
// Should overlapping intervals be accepted anyway?
std::string const g("0 [0, 1); 1 [1, 9); 3 [3, 8); 5 [5, 7); 7 [7,
maturity)");
@@ -323,6 +340,7 @@ int test_main(int, char*[])
int const n = 9;
double const d[n] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
std::string const e("5 [5, 6); 3 [2, 5); 1 [0, 2); 7");
+ // census: invalid expression cannot be pasted into GUI
std::string const g(""); // Expression is invalid.
char const* m =
"Previous interval began at duration 5;"
@@ -340,6 +358,7 @@ int test_main(int, char*[])
int const n = 10;
double const d[n] = {0, 12, 0, 27, 0, 1, 7, 7, 7, 7};
std::string const e("12 [1, @92); 27 address@hidden, @93]; 1 (@94, #1];
7");
+ census += e + "\t\t! not a partition\t\n";
std::string const g("0 [0, 1); 12 [1, @92); 0 address@hidden, @93); 27
address@hidden, @94); 0 address@hidden, @95); 1 address@hidden, 6); 7 [6,
maturity");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -351,6 +370,7 @@ int test_main(int, char*[])
int const n = 10;
double const d[n] = {0, 12.25, 0, 27.875, 0, 1.0625, 7.5, 7.5, 7.5, 7.5};
std::string const e("12.25 [1,@92); 27.875 address@hidden,@93];
1.0625(@94,#1]; 7.5");
+ census += e + "\t\t! not a partition\t\n";
std::string const g("0 [0, 1); 12.25 [1, @92); 0 address@hidden, @93);
27.875 address@hidden, @94); 0 address@hidden, @95); 1.0625 address@hidden, 6);
7.5 [6, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -360,6 +380,7 @@ int test_main(int, char*[])
int const n = 10;
double const d[n] = {1, 1, 1, 3, 3, 3, 5, 5, 5, 7};
std::string const e("1 @93; 3 @96; 5 @99; 7");
+ census += e + "\t\t\t\n";
std::string const g("1 [0, @93); 3 address@hidden, @96); 5 address@hidden,
@99); 7 address@hidden, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
}
@@ -407,6 +428,7 @@ int test_main(int, char*[])
strvec const c {"p", "p", "rrr", "rrr", "q", "q", "q", "q", "q"};
double const d[n] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
std::string const e("p[0, 2); rrr [2, 4);q[4, 6);");
+ census += "glp[0, 2); target [2, 4);gsp[4, 6);\tannual[0, 2); quarterly
[2, 4);monthly[4, 6);\t\t\n";
std::string const g("p [0, 2); rrr [2, 4); q [4, maturity)");
strvec const k{"not_used", "p", "q", "r", "rr", "rrr"};
check(__FILE__, __LINE__, n, d, e, g, "", k, c);
@@ -423,6 +445,7 @@ int test_main(int, char*[])
strvec const c {"", "", "keyword_00", "keyword_00", "", "", "", "",
""};
double const d[n] ={ 1, 1, 0 , 0 , 5, 5, 7, 7,
7};
std::string const e("1 [0, 2); keyword_00 [2, 4); 5 [4, 6); 7");
+ census += "1 [0, 2); corridor [2, 4); 5 [4, 6); 7\t\t\t\n";
std::string const g("1 [0, 2); keyword_00 [2, 4); 5 [4, 6); 7 [6,
maturity)");
strvec const k{"keyword_00"};
check(__FILE__, __LINE__, n, d, e, g, "", k, c);
@@ -437,6 +460,7 @@ int test_main(int, char*[])
strvec const c {"q", "q", "z", "p", "z", "z", "p", "z", "z", "z"};
double const d[n] = { 0 , 0 , 0 , 0 , 5 , 5 , 0 , 7 , 7 , 7 };
std::string const e("q [0, 2); p [3, 4); 5 [4, 6); p; 7");
+ census += "sevenpay [0, 2); glp [3, 4); 5 [4, 6); glp; 7\t\t! not a
partition\t\n";
std::string const g(""); // Expression is invalid.
char const* m =
"Assertion 'a_default_keyword.empty() ||"
@@ -458,6 +482,7 @@ int test_main(int, char*[])
strvec const c {"z", "z", "z", "z", "z", "z", "z", "z", "z", "z"};
double const d[n] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
std::string const e("q [0, 2); p [3, 4); 5 [4, 6); p; 7");
+ // census: invalid expression cannot be pasted into GUI
std::string const g(""); // Expression is invalid.
char const* m =
"Expected keyword chosen from { p q z }."
@@ -482,6 +507,7 @@ int test_main(int, char*[])
strvec const c {"q", "q", "z", "z", "p"};
double const d[n] = { 0 , 0 , 0 , 0 , 0 };
std::string const e("q [0, 2); p [4, maturity)");
+ census += "\tannual [0, 2); monthly [4, maturity)\t! not a partition\t\n";
// A sequence with a gap can't be created in the GUI; but how does
// the GUI translate this sequence if it's typed in?
std::string const g("q [0, 2); z [2, 4); p [4, maturity)");
@@ -501,6 +527,7 @@ int test_main(int, char*[])
strvec const c {"q", "q", "u", "u", "p"};
double const d[n] = { 0 , 0 , 0 , 0 , 0 };
std::string const e("q [0, 2); p [4, maturity)");
+ // census: invalid expression cannot be pasted into GUI
std::string const g(""); // Expression is invalid.
char const* m =
"Assertion 'a_default_keyword.empty() ||"
@@ -524,6 +551,7 @@ int test_main(int, char*[])
strvec const c {"z", "q", "q", "p", "p"};
double const d[n] = { 0 , 0 , 0 , 0 , 0 };
std::string const e("q [1, 3); p [3, maturity)");
+ census += "sevenpay [1, 3); glp [3, maturity)\tquarterly [1, 3); monthly
[3, maturity)\t! not a partition\t\n";
std::string const g("z [0, 1); q [1, 3); p [3, maturity)");
strvec const k{"p", "q", "z"};
bool const o = true;
@@ -540,6 +568,7 @@ int test_main(int, char*[])
strvec const c {"", "q", "q", "p", "p"};
double const d[n] = { 0 , 0 , 0 , 0 , 0 };
std::string const e("q [1, 3); p [3, maturity)");
+ census += "sevenpay [1, 3); glp [3, maturity)\tquarterly [1, 3); monthly
[3, maturity)\t! not a partition\t\n";
std::string const g("0 [0, 1); q [1, 3); p [3, maturity)");
strvec const k{"p", "q", "z"};
check(__FILE__, __LINE__, n, d, e, g, "", k, c);
@@ -550,6 +579,7 @@ int test_main(int, char*[])
int const n = 10;
double const d[n] = {7, 7, 7, 7, 7, 4, 4, 4, 4, 4};
std::string const e("7, retirement; 4, maturity");
+ census += e + "\t\t\t\n";
std::string const g("7 [0, retirement); 4 [retirement, maturity)");
check(__FILE__, __LINE__, n, d, e, g);
InputSequence const seq(e, 10, 90, 95, 0, 2002);
@@ -565,6 +595,7 @@ int test_main(int, char*[])
int const n = 2;
double const d[n] = {0, 0};
std::string const e("[0, 1)");
+ // census: invalid expression cannot be pasted into GUI
std::string const g(""); // Expression is invalid.
char const* m =
"Expected number or keyword."
@@ -577,6 +608,16 @@ int test_main(int, char*[])
);
}
+ std::cout
+ << "Paste into a census to test similar expressions in the GUI:\n\n"
+ << "---------8<--------8<--------8<--------"
+ << "8<--------8<--------8<--------8<-------"
+ << census
+ << "--------->8-------->8-------->8--------"
+ << ">8-------->8-------->8-------->8-------"
+ << std::endl
+ ;
+
return 0;
}
- [lmi-commits] [lmi] master updated (0cfdd92 -> 59797a5), Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master a352f9e 2/9: Restore original facet get_table() implementation, Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master da6c8c9 5/9: Do not treat tab as whitespace in UponPasteCensus(), Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master a16705a 4/9: Add a tab-is-not-ws facet, Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master 9a78453 7/9: Fix defect introduced 20160517T2303: tests not updated, Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master 1f9c757 8/9: Make certain unit tests more general, Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master 4d92a38 6/9: Allow empty strings to be pasted into a census, Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master fc4057e 3/9: Genericize, Greg Chicares, 2017/02/15
- [lmi-commits] [lmi] master 59797a5 9/9: Make unit tests pastable into GUI,
Greg Chicares <=
- [lmi-commits] [lmi] master 45a1834 1/9: Remove a dead usenet reference, Greg Chicares, 2017/02/15