[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master eff49eb 1/8: Assert more invariants
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master eff49eb 1/8: Assert more invariants |
Date: |
Thu, 23 Feb 2017 05:29:06 -0500 (EST) |
branch: master
commit eff49eb76e2ae25472c86e24e51c34f1022fe6ad
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Assert more invariants
The added invariants have been established:
- for the ctor-of-many-arguments, by fill_interval_gaps();
- for the vector ctors, by ValueInterval().
assert_not_insane_or_disordered() was made the first assertion for
InputSequence because it is a postcondition of SequenceParser, so it
is established first. This doesn't change valid observable behavior
because the order of these assertions is arbitrary.
---
input_sequence.cpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/input_sequence.cpp b/input_sequence.cpp
index 89c4724..a913126 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -302,18 +302,18 @@ std::vector<ValueInterval> const&
InputSequence::interval_representation() const
void InputSequence::realize_intervals()
{
- // Post-construction invariants.
- // Every ctor must already have established this...
- LMI_ASSERT(!intervals_.empty());
- // ...and this:
- LMI_ASSERT(years_to_maturity_ == intervals_.back().end_duration);
- // It cannot be assumed that all ctors have yet established this...
- intervals_.back().end_mode = e_maturity;
- // ...though now of course it has been established:
- LMI_ASSERT(e_maturity == intervals_.back().end_mode );
+ // 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 );
+
std::vector<double> r(years_to_maturity_);
std::vector<std::string> s(years_to_maturity_, default_keyword_);
number_result_ = r;
- [lmi-commits] [lmi] master updated (d7c4f5d -> 5753253), Greg Chicares, 2017/02/23
- [lmi-commits] [lmi] master eff49eb 1/8: Assert more invariants,
Greg Chicares <=
- [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, 2017/02/23
- [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