[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
- [lmi-commits] [lmi] master updated (d7c4f5d -> 5753253), Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master eff49eb 1/8: Assert more invariants, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 15f8d03 3/8: Assert all post-construction invariants in a single function, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 2f6ea66 6/8: Demonstrate a simplification opportunity, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 3dc9aee 2/8: Refactor to prepare for improvements,
Greg Chicares <=
- [lmi-commits] [lmi] master 3a73c40 4/8: Protect known (temporary) weak points with assertions, Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 5753253 8/8: Simplify realize_intervals(), Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 132e2ac 7/8: Simplify: only one ctor needs to call realize_intervals(), Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master 1cfefc0 5/8: Assert post-construction invariants at end of each ctor, Greg Chicares, 2017/02/23