diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-12 21:31:42 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-12 21:31:42 +0100 |
commit | 0b01d85654f802b79a93e0ab858be3a8200cae82 (patch) | |
tree | e7fd3a5b24bc6555e258085a52405d551ba0919e | |
parent | Remove unused helpers (diff) | |
download | slicer-0b01d85654f802b79a93e0ab858be3a8200cae82.tar.bz2 slicer-0b01d85654f802b79a93e0ab858be3a8200cae82.tar.xz slicer-0b01d85654f802b79a93e0ab858be3a8200cae82.zip |
Throw specific exception on unsupport model type and add covering test
-rw-r--r-- | slicer/db/sqlSelectDeserializer.cpp | 4 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.h | 5 | ||||
-rw-r--r-- | slicer/db/testSelect.cpp | 7 |
3 files changed, 15 insertions, 1 deletions
diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp index 2a499b6..96c58c1 100644 --- a/slicer/db/sqlSelectDeserializer.cpp +++ b/slicer/db/sqlSelectDeserializer.cpp @@ -7,6 +7,8 @@ namespace Slicer { TooManyRowsReturned::TooManyRowsReturned() : std::runtime_error("Too many rows returned") { } + UnsupportedModelType::UnsupportedModelType() : std::invalid_argument("Unspported model type") { } + class SqlSource : public Slicer::ValueSource, public Slicer::TValueSource<boost::posix_time::time_duration>, public Slicer::TValueSource<boost::posix_time::ptime> @@ -110,7 +112,7 @@ namespace Slicer { DeserializeSimple(mp); return; default: - throw std::invalid_argument("Unspported model type"); + throw UnsupportedModelType(); } } diff --git a/slicer/db/sqlSelectDeserializer.h b/slicer/db/sqlSelectDeserializer.h index 3d73c94..42a0243 100644 --- a/slicer/db/sqlSelectDeserializer.h +++ b/slicer/db/sqlSelectDeserializer.h @@ -16,6 +16,11 @@ namespace Slicer { TooManyRowsReturned(); }; + class UnsupportedModelType : public std::invalid_argument { + public: + UnsupportedModelType(); + }; + class DLL_PUBLIC SqlSelectDeserializer : public Slicer::Deserializer { public: SqlSelectDeserializer(DB::SelectCommand &, IceUtil::Optional<std::string> typeIdCol = IceUtil::Optional<std::string>()); diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index 7540529..3af5282 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -153,6 +153,13 @@ BoostThrowWrapperHelper(P & ... p) return Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, T>(p...); } +BOOST_AUTO_TEST_CASE( select_inherit_unsupportedModel ) +{ + auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); + auto sel = SelectPtr(db->newSelectCommand("SELECT id FROM test")); + BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<TestModule::ClassMap>(*sel), Slicer::UnsupportedModelType); +} + BOOST_AUTO_TEST_CASE( select_inherit_tooManyRowsSimple ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); |