lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4909] Begin to add product-database unit tests


From: Greg Chicares
Subject: [lmi-commits] [4909] Begin to add product-database unit tests
Date: Thu, 06 May 2010 02:26:17 +0000

Revision: 4909
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4909
Author:   chicares
Date:     2010-05-06 02:26:17 +0000 (Thu, 06 May 2010)
Log Message:
-----------
Begin to add product-database unit tests

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/database.hpp
    lmi/trunk/input_test.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-05-06 00:25:50 UTC (rev 4908)
+++ lmi/trunk/ChangeLog 2010-05-06 02:26:17 UTC (rev 4909)
@@ -25457,3 +25457,14 @@
   objects.make
 Cleanly distinguish production from the antediluvian fork.
 
+20100506T0226Z <address@hidden> [718]
+
+  database.hpp
+  input_test.cpp
+Begin to add product-database unit tests. The goal is to replace
+divergent files 'database.cpp' and 'ihs_database.cpp' with something
+solid. This command
+  grep \?\? *database*
+shows eleven marked defects, which is excessive. A glance at the code
+shows that the oft-called product_database::Query(int) is inefficient.
+

Modified: lmi/trunk/database.hpp
===================================================================
--- lmi/trunk/database.hpp      2010-05-06 00:25:50 UTC (rev 4908)
+++ lmi/trunk/database.hpp      2010-05-06 02:26:17 UTC (rev 4909)
@@ -45,6 +45,8 @@
     :private boost::noncopyable
     ,virtual private obstruct_slicing<product_database>
 {
+    friend class input_test;
+
   public:
     product_database
         (std::string const& a_ProductName

Modified: lmi/trunk/input_test.cpp
===================================================================
--- lmi/trunk/input_test.cpp    2010-05-06 00:25:50 UTC (rev 4908)
+++ lmi/trunk/input_test.cpp    2010-05-06 02:26:17 UTC (rev 4909)
@@ -27,6 +27,9 @@
 #endif // __BORLANDC__
 
 // Facilities offered by all of these headers are tested here.
+// Class product_database might appear not to belong, but it's
+// intimately entwined with input.
+#include "database.hpp"
 #include "input.hpp"
 #include "multiple_cell_document.hpp"
 #include "single_cell_document.hpp"
@@ -34,6 +37,7 @@
 // End of headers tested here.
 
 #include "assert_lmi.hpp"
+#include "dbnames.hpp"
 #include "miscellany.hpp"
 #include "test_tools.hpp"
 #include "timer.hpp"
@@ -57,12 +61,14 @@
   public:
     static void test()
         {
+        test_product_database();
         test_input_class();
         test_document_classes();
         assay_speed();
         }
 
   private:
+    static void test_product_database();
     static void test_input_class();
     static void test_document_classes();
     static void assay_speed();
@@ -83,6 +89,23 @@
     static void mete_ill_io();
 };
 
+void input_test::test_product_database()
+{
+    Input input;
+    yare_input yi(input);
+    product_database db(yi);
+    std::vector<double> v;
+
+    std::cout
+        << "\n  Database speed tests..."
+        << "\n  Init()           : " << 
TimeAnAliquot(boost::bind(&product_database::Init,            &db))
+        << "\n  ConstrainScalar(): " << 
TimeAnAliquot(boost::bind(&product_database::ConstrainScalar, &db, DB_EndtAge))
+        << "\n  Query(vector)    : " << 
TimeAnAliquot(boost::bind(&product_database::Query,           &db, v, 
DB_EndtAge))
+        << "\n  Query(scalar)    : " << 
TimeAnAliquot(boost::bind(&product_database::Query,           &db, DB_EndtAge))
+        << '\n'
+        ;
+}
+
 void input_test::test_input_class()
 {
     // Test << and >> operators.
@@ -223,12 +246,13 @@
     xml::element const& e = *i;
 
     std::cout
-        << "  Speed tests...\n"
-        << "  Overhead: " << TimeAnAliquot(mete_overhead            ) << '\n'
-        << "  Read    : " << TimeAnAliquot(boost::bind(mete_read, e)) << '\n'
-        << "  Write   : " << TimeAnAliquot(mete_write               ) << '\n'
-        << "  'cns' io: " << TimeAnAliquot(mete_cns_io              ) << '\n'
-        << "  'ill' io: " << TimeAnAliquot(mete_ill_io              ) << '\n'
+        << "\n  Input speed tests..."
+        << "\n  Overhead: " << TimeAnAliquot(mete_overhead            )
+        << "\n  Read    : " << TimeAnAliquot(boost::bind(mete_read, e))
+        << "\n  Write   : " << TimeAnAliquot(mete_write               )
+        << "\n  'cns' io: " << TimeAnAliquot(mete_cns_io              )
+        << "\n  'ill' io: " << TimeAnAliquot(mete_ill_io              )
+        << '\n'
         ;
 }
 





reply via email to

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