[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 9679edf 2/3: Add and test product_database co
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 9679edf 2/3: Add and test product_database copy ctor |
Date: |
Sun, 4 Nov 2018 21:27:45 -0500 (EST) |
branch: master
commit 9679edfe5639bfa073b8ee0e5cb25eb754adcfb7
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Add and test product_database copy ctor
Class BasicValues is movable, and is to remain so. Its
std::shared_ptr<product_database> Database_;
member is to be replaced with a plain class instance. For this
particular replacement:
product_database database_;
the product_database move ctor added two commits ago (commit 64a9cebf)
would suffice, but this preferred alternative
product_database const database_;
doesn't compile with the default move ctor--at least with gcc-7.3,
a copy ctor is required.
---
database.hpp | 2 +-
product_file_test.cpp | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/database.hpp b/database.hpp
index 2b0d391..38ccf3d 100644
--- a/database.hpp
+++ b/database.hpp
@@ -58,6 +58,7 @@ class LMI_SO product_database final
// Special ctor implemented only in a unit-test TU.
explicit product_database(int length);
product_database(product_database &&) = default;
+ product_database(product_database const&) = default;
~product_database() = default;
int length() const;
@@ -72,7 +73,6 @@ class LMI_SO product_database final
bool varies_by_state(e_database_key) const;
private:
- product_database(product_database const&) = delete;
product_database& operator=(product_database const&) = delete;
void initialize(std::string const& product_name);
diff --git a/product_file_test.cpp b/product_file_test.cpp
index 5350db4..30423b4 100644
--- a/product_file_test.cpp
+++ b/product_file_test.cpp
@@ -110,6 +110,24 @@ void product_file_test::test_copying()
BOOST_TEST(mce_s_CT == e.index().index_vector()[5]);
BOOST_TEST( 55 == e.length());
BOOST_TEST( 99 == e.Query(DB_MaxIncrAge));
+
+ // Test product_database copy ctor.
+ product_database f
+ ("sample"
+ ,mce_female
+ ,mce_standard
+ ,mce_nonsmoker
+ ,59
+ ,mce_nonmedical
+ ,mce_s_CT
+ );
+ product_database g(f);
+ BOOST_TEST(mce_s_CT == f.index().index_vector()[5]);
+ BOOST_TEST( 41 == f.length());
+ BOOST_TEST( 99 == f.Query(DB_MaxIncrAge));
+ BOOST_TEST(mce_s_CT == g.index().index_vector()[5]);
+ BOOST_TEST( 41 == g.length());
+ BOOST_TEST( 99 == g.Query(DB_MaxIncrAge));
}
void product_file_test::read_database_file()