[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master beb6154 2/2: Unit-test query_into()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master beb6154 2/2: Unit-test query_into() |
Date: |
Tue, 6 Nov 2018 05:37:23 -0500 (EST) |
branch: master
commit beb615456201075889745b266c413e5bb8566e66
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Unit-test query_into()
---
input_test.cpp | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/input_test.cpp b/input_test.cpp
index c65da42..33d6c6b 100644
--- a/input_test.cpp
+++ b/input_test.cpp
@@ -150,16 +150,31 @@ void input_test::test_product_database()
,"Assertion '1 == v.extent()' failed."
);
+ oenum_alb_or_anb a;
+
+ // This value corresponds to no enumerator, but C++ allows that.
+ db.query_into(a, DB_MaturityAge);
+ BOOST_TEST_EQUAL(100, a);
+
+ // This value is not integral, so bourn_cast rejects it.
+ BOOST_TEST_THROW
+ (db.query_into(a, DB_NaarDiscount)
+ ,std::runtime_error
+ ,"Cast would not preserve value."
+ );
+
auto f0 = [&db] {db.initialize("sample");};
auto f1 = [&db, &v] {db.Query(v, DB_MaturityAge);};
auto f2 = [&db] {db.Query(DB_MaturityAge);};
- auto f3 = [&db] {db.entity_from_key(DB_MaturityAge);};
+ auto f3 = [&db, &a] {db.query_into(a, DB_AgeLastOrNearest);};
+ auto f4 = [&db] {db.entity_from_key(DB_MaturityAge);};
std::cout
<< "\n Database speed tests..."
<< "\n initialize() : " << TimeAnAliquot(f0)
<< "\n Query(vector) : " << TimeAnAliquot(f1)
<< "\n Query(scalar) : " << TimeAnAliquot(f2)
- << "\n entity_from_key() : " << TimeAnAliquot(f3)
+ << "\n query_into(scalar): " << TimeAnAliquot(f3)
+ << "\n entity_from_key() : " << TimeAnAliquot(f4)
<< '\n'
;