diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-11-08 02:01:17 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-11-08 02:01:17 +0000 |
commit | 1def4fa9fff00ccffeec97a07ecea6457098dd90 (patch) | |
tree | c4e762617eb09a3270921ad44b37e88b075008f4 | |
parent | Test execute (diff) | |
download | libdbpp-1def4fa9fff00ccffeec97a07ecea6457098dd90.tar.bz2 libdbpp-1def4fa9fff00ccffeec97a07ecea6457098dd90.tar.xz libdbpp-1def4fa9fff00ccffeec97a07ecea6457098dd90.zip |
Test column indexing
-rw-r--r-- | libdbpp/unittests/testUtils.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libdbpp/unittests/testUtils.cpp b/libdbpp/unittests/testUtils.cpp index 578609a..34e172d 100644 --- a/libdbpp/unittests/testUtils.cpp +++ b/libdbpp/unittests/testUtils.cpp @@ -41,3 +41,20 @@ BOOST_AUTO_TEST_CASE( execute ) db->execute("UPDATE forEachRow SET a = 2"); } +BOOST_AUTO_TEST_CASE( columns ) +{ + auto db = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock")); + auto sel = DB::SelectCommandPtr(db->newSelectCommand("SELECT a, b, c, d, e FROM forEachRow ORDER BY a LIMIT 1")); + sel->execute(); + BOOST_REQUIRE_THROW((*sel)[5], DB::ColumnIndexOutOfRange); + BOOST_REQUIRE_THROW((*sel)[-1], DB::ColumnIndexOutOfRange); + BOOST_REQUIRE_EQUAL(0, (*sel)[0].colNo); + BOOST_REQUIRE_EQUAL(4, (*sel)[4].colNo); + BOOST_REQUIRE_EQUAL("c", (*sel)[2].name); + BOOST_REQUIRE_EQUAL(0, (*sel)["a"].colNo); + BOOST_REQUIRE_EQUAL(4, (*sel)["e"].colNo); + BOOST_REQUIRE_THROW((*sel)["f"], DB::ColumnDoesNotExist); + BOOST_REQUIRE_THROW((*sel)["aa"], DB::ColumnDoesNotExist); + BOOST_REQUIRE_THROW((*sel)[""], DB::ColumnDoesNotExist); +} + |