[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5807] Assert and unit-test more invariants
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5807] Assert and unit-test more invariants |
Date: |
Sun, 27 Oct 2013 11:43:41 +0000 |
Revision: 5807
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5807
Author: chicares
Date: 2013-10-27 11:43:40 +0000 (Sun, 27 Oct 2013)
Log Message:
-----------
Assert and unit-test more invariants
Modified Paths:
--------------
lmi/trunk/gpt_commutation_functions.cpp
lmi/trunk/gpt_test.cpp
Modified: lmi/trunk/gpt_commutation_functions.cpp
===================================================================
--- lmi/trunk/gpt_commutation_functions.cpp 2013-10-27 11:32:56 UTC (rev
5806)
+++ lmi/trunk/gpt_commutation_functions.cpp 2013-10-27 11:43:40 UTC (rev
5807)
@@ -206,6 +206,9 @@
/// order of magnitude slower with both gcc-3.4.5 and como-4.3.10.1,
/// as though they invoke the gpt_commfns copy ctor due to the throw-
/// expression in the conditional-expression.
+///
+/// Asserted preconditions: Duration is within its natural bounds, and
+/// other members of 'args' are nonnegative.
double gpt_cf_triad::calculate_premium
(oenum_glp_or_gsp glp_or_gsp
@@ -215,6 +218,17 @@
{
LMI_ASSERT(0 <= args.duration);
LMI_ASSERT(static_cast<unsigned int>(args.duration) < length_);
+ LMI_ASSERT(0.0 <= args.target );
+ LMI_ASSERT(0.0 <= args.f3bft );
+ LMI_ASSERT(0.0 <= args.endt_bft );
+ LMI_ASSERT(0.0 <= args.chg_sa_amt );
+ LMI_ASSERT(0.0 <= args.qab_gio_amt );
+ LMI_ASSERT(0.0 <= args.qab_adb_amt );
+ LMI_ASSERT(0.0 <= args.qab_term_amt );
+ LMI_ASSERT(0.0 <= args.qab_spouse_amt);
+ LMI_ASSERT(0.0 <= args.qab_child_amt );
+ LMI_ASSERT(0.0 <= args.qab_waiver_amt);
+
gpt_commfns const*const pcf =
(oe_glp == glp_or_gsp && mce_option1_for_7702 == dbo) ? &cf_glp_dbo_1
: (oe_glp == glp_or_gsp && mce_option2_for_7702 == dbo) ? &cf_glp_dbo_2
Modified: lmi/trunk/gpt_test.cpp
===================================================================
--- lmi/trunk/gpt_test.cpp 2013-10-27 11:32:56 UTC (rev 5806)
+++ lmi/trunk/gpt_test.cpp 2013-10-27 11:43:40 UTC (rev 5807)
@@ -341,19 +341,33 @@
initialize(0);
gpt_cf_triad const z = instantiate_cf();
+ // Negative duration.
parms.duration = -1;
BOOST_TEST_THROW
(z.calculate_premium(oe_gsp, mce_option1_for_7702, parms)
,std::runtime_error
,""
);
+ parms = s_parms(); // Reset.
+ // Duration greater than omega minus one.
parms.duration = q_m.size();
BOOST_TEST_THROW
(z.calculate_premium(oe_gsp, mce_option1_for_7702, parms)
,std::runtime_error
,""
);
+ parms = s_parms(); // Reset.
+
+ // Negative target. (Identical preconditions for other scalar
+ // parameters are not redundantly tested here.)
+ parms.target = -0.01;
+ BOOST_TEST_THROW
+ (z.calculate_premium(oe_gsp, mce_option1_for_7702, parms)
+ ,std::runtime_error
+ ,""
+ );
+ parms = s_parms(); // Reset.
}
/// The obsolescent GPT class more or less requires this ugliness.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5807] Assert and unit-test more invariants,
Greg Chicares <=