From 4a4a45e9a4a881a6c9a30722089bec7d3cc07e8c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 1 May 2021 19:29:32 +0100 Subject: Error on bad cast of referenced object --- test/test-persistence.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/test-persistence.cpp') diff --git a/test/test-persistence.cpp b/test/test-persistence.cpp index 05a02bb..a195007 100644 --- a/test/test-persistence.cpp +++ b/test/test-persistence.cpp @@ -38,6 +38,19 @@ struct SubObject : public AbsObject { } }; +struct SubObject2 : public AbsObject { + bool + persist(Persistence::PersistenceStore & store) override + { + return AbsObject::persist(store) && STORE_TYPE; + } + + void + dummy() const override + { + } +}; + struct TestObject : public Persistence::Persistable { TestObject() = default; @@ -227,6 +240,12 @@ BOOST_FIXTURE_TEST_CASE(load_shared_object_diff_default, JPP) BOOST_CHECK_NE(to->sptr, to->ssptr); } +BOOST_FIXTURE_TEST_CASE(load_shared_object_wrong_type, JPP) +{ + BOOST_CHECK_THROW(load_json>(FIXTURESDIR "json/shared_ptr_wrong_type.json"), + std::runtime_error); +} + BOOST_FIXTURE_TEST_CASE(load_shared_object_null, JPP) { auto to = load_json>(FIXTURESDIR "json/shared_ptr_null.json"); -- cgit v1.2.3