lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 3e1a780 3/4: Augment unit tests


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 3e1a780 3/4: Augment unit tests
Date: Thu, 2 Feb 2017 17:51:56 +0000 (UTC)

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

    Augment unit tests
    
    Test an all-keyword expression with a gap between intervals and a
    default keyword for filling that gap, in two situations:
     - default keyword is an element of available keywords;
     - default keyword is not an element of available keywords.
    The second situation is interesting because it is accepted although
    it seems insane, as explained in an inline comment.
---
 input_seq_test.cpp |   35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/input_seq_test.cpp b/input_seq_test.cpp
index ce4c2b0..ebefe70 100644
--- a/input_seq_test.cpp
+++ b/input_seq_test.cpp
@@ -240,8 +240,8 @@ int test_main(int, char*[])
     check(__FILE__, __LINE__, d, n, e, m);
     }
 
-    // Test intervals with 'holes'. Since the last element is replicated,
-    // there can be no 'hole' at the end.
+    // Test an expression with gaps between intervals. Because the
+    // last element is replicated, there can be no gap at the end.
     {
     int const n = 9;
     double const d[n] = {0, 1, 0, 3, 0, 5, 7, 7, 7};
@@ -387,6 +387,37 @@ int test_main(int, char*[])
     check(__FILE__, __LINE__, d, n, e, m, k, c, w, o);
     }
 
+    // Test an expression with a gap between intervals, with the
+    // keywords-only switch and a default keyword to fill the gap.
+    {
+    int const n = 5;
+    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)");
+    strvec const k{"p", "q", "z"};
+    std::string w("z");
+    bool const o = true;
+    check(__FILE__, __LINE__, d, n, e, "", k, c, w, o);
+    }
+
+    // Test an expression with a gap between intervals, with the
+    // keywords-only switch and a default keyword that is not an
+    // element of the set of allowed keywords. This test passes at
+    // the moment, but it seems insane because the values in 'c'
+    // below could not be realized from an expression 'e' that
+    // specifies a value for each year: "q;q;u;u;p" would be
+    // rejected because 'u' is not an element of {p, q, z}.
+    {
+    int const n = 5;
+    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)");
+    strvec const k{"p", "q", "z"};
+    std::string w("u");
+    bool const o = true;
+    check(__FILE__, __LINE__, d, n, e, "", k, c, w, o);
+    }
+
     // Duration keywords: {retirement, maturity}
     {
     int const n = 10;



reply via email to

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