lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 3dc9aee 2/8: Refactor to prepare for improvem


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 3dc9aee 2/8: Refactor to prepare for improvements
Date: Thu, 23 Feb 2017 05:29:06 -0500 (EST)

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

    Refactor to prepare for improvements
    
    New function assert_sane_and_ordered_partition() doesn't yet assert
    that intervals constitute a partition, but soon it will.
---
 input_sequence.cpp | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/input_sequence.cpp b/input_sequence.cpp
index a913126..58db80b 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -43,6 +43,11 @@ void assert_not_insane_or_disordered
     ,int                               years_to_maturity
     );
 
+void assert_sane_and_ordered_partition
+    (std::vector<ValueInterval> const& intervals
+    ,int                               years_to_maturity
+    );
+
 void fill_interval_gaps
     (std::vector<ValueInterval> const& in
     ,std::vector<ValueInterval>      & out
@@ -302,17 +307,7 @@ std::vector<ValueInterval> const& 
InputSequence::interval_representation() const
 
 void InputSequence::realize_intervals()
 {
-    // Post-construction invariants that every ctor has already established.
-
-    assert_not_insane_or_disordered(intervals_, years_to_maturity_);
-
-    LMI_ASSERT(!intervals_.empty());
-
-    LMI_ASSERT(0                  == intervals_.front().begin_duration);
-    LMI_ASSERT(e_inception        == intervals_.front().begin_mode    );
-
-    LMI_ASSERT(years_to_maturity_ == intervals_.back().end_duration);
-    LMI_ASSERT(e_maturity         == intervals_.back().end_mode    );
+    assert_sane_and_ordered_partition(intervals_, years_to_maturity_);
 
     std::vector<double>      r(years_to_maturity_);
     std::vector<std::string> s(years_to_maturity_, default_keyword_);
@@ -436,6 +431,22 @@ void assert_not_insane_or_disordered
         }
 }
 
+void assert_sane_and_ordered_partition
+    (std::vector<ValueInterval> const& intervals
+    ,int                               years_to_maturity
+    )
+{
+    assert_not_insane_or_disordered(intervals, years_to_maturity);
+
+    LMI_ASSERT(!intervals.empty());
+
+    LMI_ASSERT(0                 == intervals.front().begin_duration);
+    LMI_ASSERT(e_inception       == intervals.front().begin_mode    );
+
+    LMI_ASSERT(years_to_maturity == intervals.back().end_duration);
+    LMI_ASSERT(e_maturity        == intervals.back().end_mode    );
+}
+
 /// Create a partition of [0, maturity) from parser output.
 ///
 /// The last interval's endpoint is extended to maturity, replicating



reply via email to

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