[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 88fbe0c 4/6: Overload calculate_premium()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 88fbe0c 4/6: Overload calculate_premium() |
Date: |
Thu, 22 Apr 2021 11:57:26 -0400 (EDT) |
branch: master
commit 88fbe0ce12dc06f62c2928dc1733584bfc7e6b32
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Overload calculate_premium()
The overload that overrides 'args.dbopt_7702' is for unit testing only.
---
gpt_cf_triad_test.cpp | 8 ++++----
gpt_commutation_functions.cpp | 12 ++++++++++++
gpt_commutation_functions.hpp | 11 ++++++-----
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/gpt_cf_triad_test.cpp b/gpt_cf_triad_test.cpp
index ff9cc71..40acdc1 100644
--- a/gpt_cf_triad_test.cpp
+++ b/gpt_cf_triad_test.cpp
@@ -340,7 +340,7 @@ void gpt_cf_triad_test::test_preconditions()
// Negative duration.
parms.duration = -1;
LMI_TEST_THROW
- (z.calculate_premium(oe_gsp, parms, mce_option1_for_7702)
+ (z.calculate_premium(oe_gsp, parms)
,std::runtime_error
,""
);
@@ -349,7 +349,7 @@ void gpt_cf_triad_test::test_preconditions()
// Duration greater than omega minus one.
parms.duration = lmi::ssize(q_m);
LMI_TEST_THROW
- (z.calculate_premium(oe_gsp, parms, mce_option1_for_7702)
+ (z.calculate_premium(oe_gsp, parms)
,std::runtime_error
,""
);
@@ -359,7 +359,7 @@ void gpt_cf_triad_test::test_preconditions()
// parameters are not redundantly tested here.)
parms.target_prem = -0.01;
LMI_TEST_THROW
- (z.calculate_premium(oe_gsp, parms, mce_option1_for_7702)
+ (z.calculate_premium(oe_gsp, parms)
,std::runtime_error
,""
);
@@ -369,7 +369,7 @@ void gpt_cf_triad_test::test_preconditions()
parms.endt_bft = 100000.0;
parms.f3_bft = 90000.0;
LMI_TEST_THROW
- (z.calculate_premium(oe_gsp, parms, mce_option1_for_7702)
+ (z.calculate_premium(oe_gsp, parms)
,std::runtime_error
,""
);
diff --git a/gpt_commutation_functions.cpp b/gpt_commutation_functions.cpp
index 567b545..46bd140 100644
--- a/gpt_commutation_functions.cpp
+++ b/gpt_commutation_functions.cpp
@@ -230,6 +230,10 @@ gpt_cf_triad::gpt_cf_triad
/// Asserted postcondition: Returned GLP or GSP is nonnegative; thus,
/// while adjusted premium 'A+B-C' may be negative, {A,B,C} are all
/// individually nonnegative.
+///
+/// This overload accepts a 'dbo' argument, specifying a death benefit
+/// option that may differ from 'args.dbopt_7702'; it is intended only
+/// for unit testing.
double gpt_cf_triad::calculate_premium
(oenum_glp_or_gsp glp_or_gsp
@@ -262,3 +266,11 @@ double gpt_cf_triad::calculate_premium
LMI_ASSERT(0.0 <= z);
return z;
}
+
+double gpt_cf_triad::calculate_premium
+ (oenum_glp_or_gsp glp_or_gsp
+ ,gpt_scalar_parms const& args
+ ) const
+{
+ return calculate_premium(glp_or_gsp, args, args.dbopt_7702);
+}
diff --git a/gpt_commutation_functions.hpp b/gpt_commutation_functions.hpp
index 7ebc094..54dc460 100644
--- a/gpt_commutation_functions.hpp
+++ b/gpt_commutation_functions.hpp
@@ -81,10 +81,7 @@ struct gpt_vector_parms
/// both GLP and GSP.
///
/// 'mcenum_dbopt_7702' is included here even though it's irrelevant
-/// for GSP. 7702 !! Therefore the gpt_cf_triad::calculate_premium()
-/// 'mcenum_dbopt_7702' argument seems redundant; should it be
-/// eradicated, or be retained as an optional argument for unit
-/// testing only?
+/// for GSP.
///
/// 'chg_sa_base' is the base for any specified-amount load. It may
/// differ from 'specamt', e.g., by being limited to a scalar maximum,
@@ -204,6 +201,8 @@ class gpt_commfns
class gpt_cf_triad
{
+ friend class gpt_cf_triad_test;
+
public:
gpt_cf_triad
(std::vector<double> const& qc
@@ -214,13 +213,15 @@ class gpt_cf_triad
,gpt_vector_parms const& charges
);
+ double calculate_premium(oenum_glp_or_gsp, gpt_scalar_parms const&) const;
+
+ private:
double calculate_premium
(oenum_glp_or_gsp
,gpt_scalar_parms const&
,mcenum_dbopt_7702
) const;
- private:
int const length_;
gpt_commfns cf_glp_dbo_1;
gpt_commfns cf_glp_dbo_2;
- [lmi-commits] [lmi] master updated (905df77 -> 718ef64), Greg Chicares, 2021/04/22
- [lmi-commits] [lmi] master d53539c 1/6: Rebuild 'custom_tools' early in 'hooks/pre-commit', Greg Chicares, 2021/04/22
- [lmi-commits] [lmi] master 60b5d97 2/6: Strenghen asserted preconditions, Greg Chicares, 2021/04/22
- [lmi-commits] [lmi] master 718ef64 6/6: Enforce a minimum single premium for "corridor" strategy, Greg Chicares, 2021/04/22
- [lmi-commits] [lmi] master 8d6c2da 3/6: Transpose two arguments, Greg Chicares, 2021/04/22
- [lmi-commits] [lmi] master 88fbe0c 4/6: Overload calculate_premium(),
Greg Chicares <=
- [lmi-commits] [lmi] master 37944d8 5/6: Add database entities for a minimum single premium, Greg Chicares, 2021/04/22