lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 64a9ceb 3/3: Add and test product_database mo


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 64a9ceb 3/3: Add and test product_database move ctor
Date: Sun, 4 Nov 2018 03:10:23 -0500 (EST)

branch: master
commit 64a9cebfb9ec100dcb0e22d77bd6d581d3624e88
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Add and test product_database move ctor
---
 database.hpp          |  1 +
 product_file_test.cpp | 22 +++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/database.hpp b/database.hpp
index 84da5f1..2b0d391 100644
--- a/database.hpp
+++ b/database.hpp
@@ -57,6 +57,7 @@ class LMI_SO product_database final
     explicit product_database(yare_input const&);
     // Special ctor implemented only in a unit-test TU.
     explicit product_database(int length);
+    product_database(product_database &&) = default;
     ~product_database() = default;
 
     int length() const;
diff --git a/product_file_test.cpp b/product_file_test.cpp
index 6e62f89..5350db4 100644
--- a/product_file_test.cpp
+++ b/product_file_test.cpp
@@ -22,6 +22,7 @@
 #include "pchfile.hpp"
 
 #include "data_directory.hpp"           // AddDataDir()
+#include "database.hpp"
 #include "dbdict.hpp"
 #include "fund_data.hpp"
 #include "global_settings.hpp"
@@ -34,6 +35,7 @@
 #include "timer.hpp"
 
 #include <string>
+#include <utility>                      // move()
 
 class product_file_test
 {
@@ -84,12 +86,30 @@ void product_file_test::test_copying()
 {
     product_data p(policy_filename_);
 
-    // Test copy ctor.
+    // Test product_data copy ctor.
     product_data q(p);
     BOOST_TEST(database_filename_   == 
AddDataDir(q.datum("DatabaseFilename")));
     BOOST_TEST(fund_filename_       == AddDataDir(q.datum("FundFilename"    
)));
     BOOST_TEST(rounding_filename_   == 
AddDataDir(q.datum("RoundingFilename")));
     BOOST_TEST(stratified_filename_ == AddDataDir(q.datum("TierFilename"    
)));
+
+    // Test product_database move ctor.
+    product_database d
+        ("sample"
+        ,mce_female
+        ,mce_standard
+        ,mce_nonsmoker
+        ,45
+        ,mce_nonmedical
+        ,mce_s_CT
+        );
+    BOOST_TEST(mce_s_CT == d.index().index_vector()[5]);
+    BOOST_TEST(      55 == d.length());
+    BOOST_TEST(      99 == d.Query(DB_MaxIncrAge));
+    product_database e(std::move(d));
+    BOOST_TEST(mce_s_CT == e.index().index_vector()[5]);
+    BOOST_TEST(      55 == e.length());
+    BOOST_TEST(      99 == e.Query(DB_MaxIncrAge));
 }
 
 void product_file_test::read_database_file()



reply via email to

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