lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 49ee20b 4/5: Validate products


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 49ee20b 4/5: Validate products
Date: Thu, 19 Nov 2020 19:00:12 -0500 (EST)

branch: master
commit 49ee20b310ce1e8819f95381305a28779832729a
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Validate products
    
    The immediate purpose is to iterate over all products and states, in
    order to test whether the old '.policy' and new '.lingo' methods produce
    the same strings--although this test is otherwise generally useful. This
    commit subsumes the throwaway 'odd/test_all_products' branch mentioned
    here:
      https://lists.nongnu.org/archive/html/lmi/2020-11/msg00020.html
    and that branch may soon be removed.
    
    Replaced an old 'gprof' command-line option with this new one, because
    'perf' is generally preferable to 'gprof'.
---
 ce_product_name.hpp |  3 ++-
 ihs_acctval.cpp     | 11 ++++++++++-
 main_cli.cpp        | 45 +++++++++++++++++++++++++++++++++++++++------
 3 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/ce_product_name.hpp b/ce_product_name.hpp
index 708c561..165f515 100644
--- a/ce_product_name.hpp
+++ b/ce_product_name.hpp
@@ -25,6 +25,7 @@
 #include "config.hpp"
 
 #include "mc_enum.hpp"
+#include "so_attributes.hpp"
 
 #include <iosfwd>
 #include <string>
@@ -51,7 +52,7 @@
 /// possible without adjusting the base class's 'allowed_' vector and
 /// perhaps changing the way ordinal() works?
 
-class ce_product_name
+class LMI_SO ce_product_name
     :public mc_enum_base
 {
   public:
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 98851dc..da16504 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -539,7 +539,16 @@ void AccountValue::SetInitialValues()
     AVGenAcct                   = InforceAVGenAcct;
     AVSepAcct                   = InforceAVSepAcct;
 
-    SepAcctPaymentAllocation = premium_allocation_to_sepacct(yare_input_);
+    // WX PORT !! When fund selection is finally ported from ihs,
+    // this workaround should not be needed; until then, it sidesteps
+    // spurious errors in product_test().
+    double const sa_allocation =  premium_allocation_to_sepacct(yare_input_);
+    bool const override_allocation =
+           !database().query<bool>(DB_AllowGenAcct)
+        && global_settings::instance().regression_testing()
+        ;
+//  SepAcctPaymentAllocation = premium_allocation_to_sepacct(yare_input_);
+    SepAcctPaymentAllocation = override_allocation ? 1.0 : sa_allocation ;
     GenAcctPaymentAllocation = 1.0 - SepAcctPaymentAllocation;
 
     if(!database().query<bool>(DB_AllowGenAcct) && 0.0 != 
GenAcctPaymentAllocation)
diff --git a/main_cli.cpp b/main_cli.cpp
index 67639ea..ec12b53 100644
--- a/main_cli.cpp
+++ b/main_cli.cpp
@@ -29,6 +29,7 @@
 #include "getopt.hpp"
 #include "global_settings.hpp"
 #include "gpt_server.hpp"
+#include "handle_exceptions.hpp"        // report_exception()
 #include "illustrator.hpp"
 #include "input.hpp"
 #include "ledger.hpp"
@@ -168,13 +169,45 @@ void self_test()
 #endif // !defined _GLIBCXX_DEBUG
 }
 
-/// Run self-test repeatedly (intended for use with 'gprof').
+/// Validate products.
+///
+/// Run an illustration for every product in every state (whether
+/// approved there or not), reporting any conflict in parameters
+/// that would make that impossible. See:
+///   https://lists.nongnu.org/archive/html/lmi/2020-11/msg00020.html
 
-void profile()
+void product_test()
 {
-    for(int j = 0; j < 10; ++j)
+    // Allow unapproved states.
+    global_settings::instance().set_regression_testing(true);
+
+    // Pay zero and don't solve, to make this test go faster.
+    Input input;
+    input["Payment"           ] = "0.0";
+    input["SolveType"         ] = "No solve";
+
+    illustrator z(mce_emit_nothing);
+
+    ce_product_name c;
+    std::vector<std::string> const& p = c.all_strings();
+    std::vector<std::string> const& s = all_strings_state();
+    for(auto const& i : p)
         {
-        self_test();
+        std::cout << "Testing product " << i << std::endl;
+        input["ProductName"        ] = i;
+        for(auto const& j : s)
+            {
+            input["StateOfJurisdiction"] = j;
+            try
+                {
+                z("eraseme", input);
+                }
+            catch(...)
+                {
+                std::cout << i << ", " << j << ":" << std::endl;
+                report_exception();
+                }
+            }
         }
 }
 
@@ -194,7 +227,7 @@ void process_command_line(int argc, char* argv[])
         {"file"         ,REQD_ARG ,nullptr ,'f' ,nullptr ,"input file to run"},
         {"help"         ,NO_ARG   ,nullptr ,'h' ,nullptr ,"display this help 
and exit"},
         {"license"      ,NO_ARG   ,nullptr ,'l' ,nullptr ,"display license and 
exit"},
-        {"profile"      ,NO_ARG   ,nullptr ,'o' ,nullptr ,"set up for 
profiling and exit"},
+        {"product_test" ,NO_ARG   ,nullptr ,'o' ,nullptr ,"validate products 
and exit"},
         {"print_db"     ,NO_ARG   ,nullptr ,'p' ,nullptr ,"print products and 
exit"},
         {"selftest"     ,NO_ARG   ,nullptr ,'s' ,nullptr ,"perform self test 
and exit"},
         {"test_db"      ,NO_ARG   ,nullptr ,'t' ,nullptr ,"test products and 
exit"},
@@ -389,7 +422,7 @@ void process_command_line(int argc, char* argv[])
 
             case 'o':
                 {
-                profile();
+                product_test();
                 return;
                 }
                 break;



reply via email to

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