Web Wispers 1.2.1 C++ Unit Test Coverage
Current view: top level - tests/wispers/database - DatabaseTest.cc (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.1 C++ Unit Tests Lines: 203 203 100.0 %
Date: 2011-11-11 Functions: 65 69 94.2 %
Branches: 2097 4252 49.3 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright 2006-2009 Savarese Software Research Corporation
       3                 :            :  *
       4                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       5                 :            :  * you may not use this file except in compliance with the License.
       6                 :            :  * You may obtain a copy of the License at
       7                 :            :  *
       8                 :            :  *     http://www.savarese.com/software/ApacheLicense-2.0
       9                 :            :  *
      10                 :            :  * Unless required by applicable law or agreed to in writing, software
      11                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      12                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13                 :            :  * See the License for the specific language governing permissions and
      14                 :            :  * limitations under the License.
      15                 :            :  */
      16                 :            : 
      17                 :            : #include <tests/TestCommon.h>
      18                 :            : #include <ssrc/wispers/database/MultiRowOperations.h>
      19                 :            : #include <ssrc/wispers/database/InitializeLibrary.h>
      20                 :            : #include <ssrc/wispers/utility/AppendToContainer.h>
      21                 :            : #include <ssrc/wispers/types.h>
      22                 :            : 
      23                 :            : using namespace NS_SSRC_WSPR_DATABASE;
      24                 :            : using NS_SSRC_WSPR_UTILITY::AppendToContainer;
      25                 :            : 
      26   [ +  -  +  -  :        194 : WSPR_DB_ROW_WITH_KEY(foo, ((string, bar))((int, baz)), (1))
          +  -  +  -  +  
          -  +  -  +  -  
          +  +  -  +  -  
             +  -  +  - ]
      27   [ +  -  +  -  :         76 : WSPR_DB_ROW(two_key_type0, ((int, key0))((int, key1)))
          +  -  +  -  +  
          +  -  +  -  +  
                -  +  - ]
      28                 :          5 : WSPR_DB_ROW_WITH_KEY(two_key_type1, ((int, key0))((string, bar))((int, key1)), (0)(2))
      29                 :            : 
      30                 :            : WSPR_DB_ROW_WITH_KEY(uint_type,
      31   [ +  -  +  -  :        147 :                      ((unsigned int, num32))((std::uint64_t, num64))((std::uint16_t, num16)), (0)(1)(2))
          +  -  #  #  #  
          #  #  #  #  #  
             #  #  +  - ]
      32                 :            : 
      33                 :            : using std::get;
      34                 :            : 
      35   [ +  -  +  -  :         21 : class DatabaseTest : public TestCase {
             -  +  +  - ]
      36                 :            : 
      37                 :            :   InitializeLibrary _init_lib;
      38                 :            :   boost::scoped_ptr<Database> db;
      39                 :            : 
      40                 :            :   typedef MultiRowOperations<foo> row_ops;
      41                 :            :   typedef MultiRowOperations<two_key_type0> two_ops;
      42                 :            : 
      43                 :            : public:
      44                 :            : 
      45                 :          7 :   virtual void setUp() {
      46   [ +  -  +  -  :          7 :     db.reset(new Database());
          +  -  +  -  +  
                      - ]
      47                 :          7 :   }
      48                 :            : 
      49                 :          7 :   virtual void tearDown() {
      50                 :          7 :     db.reset();
      51                 :          7 :   }
      52                 :            : 
      53                 :          5 :   void init_data() {
      54                 :            :     prepared_statement_ptr statement =
      55   [ +  -  +  -  :         10 :       db->prepare("CREATE TABLE `foo` (`bar` CHAR(4), `baz` INTEGER PRIMARY KEY);");
                   +  - ]
      56                 :            : 
      57   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(!statement->expired());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
      58   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(0 == statement->count_parameters());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
      59   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(0 == statement->count_columns());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
      60                 :            : 
      61   [ +  -  +  -  :         10 :     QueryResult result = statement->execute();
                   +  - ]
      62                 :            : 
      63   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(!result.result_set);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      64   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(0 == result.changes);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      65                 :            : 
      66   [ +  -  +  -  :          5 :     statement = db->prepare("INSERT INTO `foo` VALUES('foo', 42);");
          +  -  +  -  +  
                      - ]
      67                 :            : 
      68   [ +  -  +  -  :          5 :     result = statement->execute();
             +  -  +  - ]
      69                 :            : 
      70   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(!result.result_set);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      71   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(1 == result.changes);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      72   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(0 == statement->count_columns());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
      73                 :            : 
      74   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(1 == std::tuple_size<foo::primary_key_columns_type>::value);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      75         [ +  - ]:          5 :     foo::primary_key_columns_type foocols = foo::primary_key_columns();
      76   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<0>(foocols) == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
      77   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(foo::Key<0>::column == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      78                 :            : 
      79   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(2 == std::tuple_size<two_key_type0::primary_key_columns_type>::value);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      80                 :            :     two_key_type0::primary_key_columns_type tkt0cols =
      81         [ +  - ]:          5 :       two_key_type0::primary_key_columns();
      82   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<0>(tkt0cols) == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
      83   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<1>(tkt0cols) == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
      84   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(two_key_type0::Key<0>::column == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      85   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(two_key_type0::Key<1>::column == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      86                 :            : 
      87   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(2 == std::tuple_size<two_key_type1::primary_key_columns_type>::value);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      88                 :            :     two_key_type1::primary_key_columns_type tkt1cols =
      89         [ +  - ]:          5 :       two_key_type1::primary_key_columns();
      90   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<0>(tkt1cols) == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
      91   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<1>(tkt1cols) == 2);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
      92   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(two_key_type1::Key<0>::column == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      93   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(two_key_type1::Key<1>::column == 2);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      94                 :            : 
      95                 :            : 
      96   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(3 == std::tuple_size<uint_type::primary_key_columns_type>::value);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
      97                 :            :     uint_type::primary_key_columns_type uintcols =
      98         [ +  - ]:          5 :       uint_type::primary_key_columns();
      99   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<0>(uintcols) == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     100   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<1>(uintcols) == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     101   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(std::get<2>(uintcols) == 2);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     102   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(uint_type::Key<0>::column == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     103   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(uint_type::Key<1>::column == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     104   [ +  -  +  -  :          5 :     CPPUNIT_ASSERT(uint_type::Key<2>::column == 2);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     105                 :          5 :   }
     106                 :            : 
     107                 :          1 :   void test_null_min_max() {
     108                 :            :     using namespace NS_SSRC_WSPR;
     109   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(null_row_id<row_id_type>() == NullRowId);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     110   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(min_row_id<row_id_type>() == MinRowId);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     111                 :          1 :   }
     112                 :            : 
     113                 :          1 :   void test_prepare_statement() {
     114                 :          1 :     init_data();
     115                 :            : 
     116                 :            :     prepared_statement_ptr statement =
     117   [ +  -  +  -  :          2 :       db->prepare("SELECT * FROM `foo` WHERE `bar` = 'foo';");
                   +  - ]
     118                 :            : 
     119   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(2 == statement->count_columns());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     120   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(statement->column_name(0) == "bar");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
     121   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(statement->column_name(1) == "baz");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
     122                 :            : 
     123   [ +  -  +  -  :          2 :     QueryResult result = statement->execute();
                   +  - ]
     124                 :            : 
     125   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     126   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(0 == result.changes);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     127   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(2 == result.result_set->count_values());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     128   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set->value<string>(0) == "foo");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     129   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set->value<int>(1) == 42);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     130   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set->value<string>(1) == "42");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     131   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set->column_type(0) == ResultSet::Text);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     132   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set->column_type(1) == ResultSet::Integer);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     133   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set->value<blob_type>(0).second == 3);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     134                 :            : 
     135                 :            :     typedef std::tuple<string, int> row_type;
     136   [ +  -  +  - ]:          2 :     row_type row = result.result_set->values<row_type>();
     137                 :            : 
     138   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<0>(row) == "foo");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     139   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<1>(row) == 42);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     140                 :            : 
     141   [ +  -  +  -  :          1 :     row = *result.result_set;
                   +  - ]
     142                 :            : 
     143   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<0>(row) == "foo");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     144   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<1>(row) == 42);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     145                 :            : 
     146   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(!result.result_set->next());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     147                 :            : 
     148   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT_NO_THROW(statement->execute());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     149                 :          1 :   }
     150                 :            : 
     151                 :          1 :   void test_bind() {
     152                 :          1 :     init_data();
     153                 :            : 
     154                 :            :     prepared_statement_ptr statement =
     155   [ +  -  +  -  :          2 :       db->prepare("SELECT * FROM `foo` WHERE `bar` = ? AND `baz` = ?;");
                   +  - ]
     156                 :            : 
     157   [ +  -  +  -  :          2 :     QueryResult result = statement->execute("foo", 42);
                   +  - ]
     158                 :            : 
     159   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     160   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(0 == result.changes);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     161   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(2 == result.result_set->count_values());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     162                 :            : 
     163                 :            :     std::tuple<string, int> row =
     164   [ +  -  +  - ]:          2 :       result.result_set->values<string, int>();
     165                 :            : 
     166   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<0>(row) == "foo");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     167   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<1>(row) == 42);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     168                 :            : 
     169   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(!result.result_set->next());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     170                 :            : 
     171                 :          1 :     const char *foo = "blah";
     172         [ +  - ]:          1 :     blob_type blob(foo, 5);
     173                 :            : 
     174   [ +  -  +  -  :          1 :     db->prepare("INSERT INTO `foo` VALUES(x'626C616800', 43);")->execute();
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     175                 :            : 
     176   [ +  -  +  -  :          1 :     result = statement->execute(blob, 43);
             +  -  +  - ]
     177                 :            : 
     178   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.result_set);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     179   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(0 == result.changes);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     180   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(2 == result.result_set->count_values());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     181                 :            : 
     182                 :            :     std::tuple<blob_type, int> blob_row =
     183         [ +  - ]:          1 :       result.result_set->values<blob_type, int>();
     184   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<0>(blob_row).second == 5);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     185   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(string("blah") ==
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     186         [ +  - ]:          1 :                    static_cast<const char*>(get<0>(blob_row).first));
     187                 :          1 :   }
     188                 :            : 
     189                 :          1 :   void test_row_type() {
     190                 :          1 :     init_data();
     191                 :            : 
     192   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(!foo::is_primary_key(0));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     193   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(foo::is_primary_key(1));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     194   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(!foo::is_primary_key<0>());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     195   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(foo::is_primary_key<1>());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     196                 :            : 
     197   [ +  -  +  -  :          2 :     foo row("bar", 8);
                   +  - ]
     198   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(8 == row.primary_key_value());
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     199                 :            : 
     200                 :          1 :     two_key_type0 two_row(9, 8);
     201   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<0>(two_row.primary_key_value()) == 9);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     202   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(get<1>(two_row.primary_key_value()) == 8);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     203                 :          1 :   }
     204                 :            : 
     205                 :            :   template<bool specify_columns>
     206                 :          2 :   void test_row_operations() {
     207                 :          2 :     init_data();
     208                 :            : 
     209   [ +  -  +  -  :          4 :     row_ops crud(*db, DefaultValueBinder(), DefaultValueLoader(), specify_columns);
             +  -  +  - ]
     210   [ +  -  +  -  :          4 :     row_ops::find_result_type result = crud.find(42);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     211                 :            : 
     212   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     213   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result.second == foo("foo", 42));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     214                 :            : 
     215   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.exists(42));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     216   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.exists(result.second));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     217                 :            : 
     218   [ +  -  +  -  :          4 :     foo foo_row, foo_row2;
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     219                 :            : 
     220   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.find(42, foo_row));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     221   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(foo_row == result.second);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     222                 :            : 
     223   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.find(foo_row, foo_row2));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     224   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(foo_row2 == foo_row);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     225                 :            : 
     226   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.save(foo("bar", 42)));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     227   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(!crud.insert(foo("bar", 42)));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     228   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.insert(foo("blah", 991)));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     229                 :            : 
     230   [ +  -  +  -  :          2 :     result = crud.find(42);
          +  -  +  -  +  
                -  +  - ]
     231   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     232   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result.second == foo("bar", 42));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     233                 :            : 
     234   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.save(foo("baz", 45)));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     235                 :            : 
     236   [ +  -  +  -  :          2 :     result = crud.find(45);
          +  -  +  -  +  
                -  +  - ]
     237   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result.second == foo("baz", 45));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     238                 :            : 
     239                 :          2 :     int keys[3] = { 42, 45, 991 };
     240   [ +  -  +  -  :          4 :     std::vector<foo> values;
             +  -  +  - ]
     241                 :            : 
     242   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.for_each_row(&keys[0], &keys[3], 3, AppendToContainer<std::vector<foo> >(values)) == 3);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     243                 :            : 
     244   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(values[0].baz == 42);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     245   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(values[0].bar == "bar");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     246   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(values[1].baz == 45);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     247   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(values[1].bar == "baz");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     248   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(values[2].baz == 991);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     249   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(values[2].bar == "blah");
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     250                 :            : 
     251   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud.erase(result.second) == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     252   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(!crud.find(45).first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     253                 :            : 
     254   [ +  -  +  -  :          2 :     db->execute("CREATE TABLE `two_key_type0` (`key0` INTEGER, `key1` INTEGER,  PRIMARY KEY (`key0`, `key1`));");
          +  -  +  -  +  
                -  +  - ]
     255                 :            : 
     256   [ +  -  +  -  :          4 :     two_ops crud2(*db, DefaultValueBinder(), DefaultValueLoader(), specify_columns);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     257                 :            : 
     258   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud2.save(two_key_type0(19, 24)));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     259                 :            : 
     260                 :            :     two_ops::find_result_type result2 =
     261   [ +  -  +  -  :          2 :       crud2.find(two_key_type0::primary_key_type(19, 24));
          +  -  +  -  +  
                -  +  - ]
     262                 :            : 
     263   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result2.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     264   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result2.second == two_key_type0(19, 24));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     265                 :            : 
     266   [ +  -  +  -  :          2 :     result2 = crud2.find(19, 24);
             +  -  +  - ]
     267                 :            : 
     268   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result2.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     269   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result2.second == two_key_type0(19, 24));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     270                 :            : 
     271   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud2.exists(result2.second));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     272   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud2.exists(19, 24));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     273                 :            : 
     274   [ +  -  +  -  :          2 :     result2 = crud2.find(result2.second);
             +  -  +  - ]
     275                 :            : 
     276   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result2.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     277   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(result2.second == two_key_type0(19, 24));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     278                 :            : 
     279                 :            :     two_key_type0::primary_key_type keys2[1] = {
     280                 :            :       two_key_type0::primary_key_type(19, 24)
     281   [ +  -  +  - ]:          2 :     };
     282   [ +  -  +  -  :          4 :     std::vector<two_key_type0> values2;
             +  -  +  - ]
     283                 :            : 
     284   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud2.for_each_row(&keys2[0], &keys2[1], 1, AppendToContainer<std::vector<two_key_type0> >(values2)) == 1);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     285   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(values2[0] == two_key_type0(19, 24));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     286                 :            : 
     287   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(crud2.erase(result2.second));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     288                 :            : 
     289   [ +  -  +  -  :          2 :     result2 = crud2.find(result2.second);
             +  -  +  - ]
     290                 :            : 
     291   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(!result2.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     292                 :            : 
     293   [ +  -  +  -  :          2 :     CPPUNIT_ASSERT(!crud2.erase(19, 24));
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  +  - ]
     294                 :          2 :   }
     295                 :            : 
     296                 :            :   // This isn't a real unit test.  It is to determine whether or not
     297                 :            :   // unsigned integers outside of the signed int range are preserved.
     298                 :          1 :   void test_uint() {
     299   [ +  -  +  -  :          1 :     db->execute("CREATE TABLE `uint_type` (`num32` INTEGER, `num64` INTEGER, `num16` INTEGER,  PRIMARY KEY (`num32`, `num64`, `num16`));");
                   +  - ]
     300                 :            : 
     301                 :          1 :     const unsigned int max16 = boost::integer_traits<std::uint16_t>::const_max;
     302                 :          1 :     const unsigned int max32 = boost::integer_traits<unsigned int>::const_max;
     303                 :          1 :     const std::uint64_t max64 = boost::integer_traits<std::uint64_t>::const_max;
     304   [ +  -  +  - ]:          2 :     RowOperations<uint_type> crud(*db);
     305                 :            : 
     306   [ +  -  +  +  :         33 :     for(unsigned int i = 1, j =0; i < max32 && j < 32; i*=2, ++j) {
                   +  + ]
     307                 :         32 :       const std::uint16_t num16 = max16 - i + 1;
     308                 :         32 :       const unsigned int num32 = max32 - i + 1;
     309                 :         32 :       const std::uint64_t num64 = max64 - i + 1;
     310                 :            : 
     311         [ +  - ]:         32 :       crud.save(uint_type(num32, num64, num16));
     312                 :            : 
     313                 :            :       RowOperations<uint_type>::find_result_type result =
     314   [ +  -  +  -  :         32 :         crud.find(uint_type::primary_key_type(num32, num64, num16));
                   +  - ]
     315                 :            : 
     316   [ +  -  +  -  :         32 :       CPPUNIT_ASSERT(result.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     317   [ +  -  +  -  :         32 :       CPPUNIT_ASSERT(result.second.num32 == num32);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     318   [ +  -  +  -  :         32 :       CPPUNIT_ASSERT(result.second.num64 == num64);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     319   [ +  -  +  -  :         32 :       CPPUNIT_ASSERT(result.second.num16 == num16);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     320                 :            :     }
     321                 :            : 
     322                 :            : 
     323         [ +  - ]:          1 :     crud.save(uint_type(0, 0, 0));
     324                 :            : 
     325                 :            :     RowOperations<uint_type>::find_result_type result =
     326   [ +  -  +  -  :          1 :       crud.find(uint_type::primary_key_type(0, 0, 0));
                   +  - ]
     327                 :            : 
     328   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.first);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     329   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.second.num32 == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     330   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.second.num64 == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     331   [ +  -  +  -  :          1 :     CPPUNIT_ASSERT(result.second.num16 == 0);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]
     332                 :          1 :   }
     333                 :            : 
     334   [ +  -  +  -  :          4 :   CPPUNIT_TEST_SUITE(DatabaseTest);
             +  -  #  # ]
     335   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_null_min_max);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     336   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_prepare_statement);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     337   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_bind);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     338   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_row_type);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     339   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_row_operations<row_ops::ImplicitColumns>);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     340   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_row_operations<row_ops::ExplicitColumns>);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     341   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_uint);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
     342                 :            : 
     343   [ +  -  +  -  :          2 :   CPPUNIT_TEST_SUITE_END();
          +  -  +  -  +  
                -  +  - ]
     344                 :            : };
     345                 :            : 
     346   [ -  +  #  # ]:          1 : CPPUNIT_TEST_SUITE_REGISTRATION(DatabaseTest);
     347   [ +  -  +  -  :          4 : WISP_TEST_MAIN()
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]