diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-14 18:14:54 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-03-14 18:14:54 +0000 |
commit | 2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07 (patch) | |
tree | 751ac31e6a0e38fb5f17040da3937856fad7f111 /test | |
parent | Globally enable GLM vector swizzles (diff) | |
download | ilt-2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07.tar.bz2 ilt-2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07.tar.xz ilt-2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07.zip |
Add postLoad support to persistence
Diffstat (limited to 'test')
-rw-r--r-- | test/test-persistence.cpp | 7 | ||||
-rw-r--r-- | test/testStructures.cpp | 6 | ||||
-rw-r--r-- | test/testStructures.h | 3 |
3 files changed, 16 insertions, 0 deletions
diff --git a/test/test-persistence.cpp b/test/test-persistence.cpp index a72c481..38bbf2f 100644 --- a/test/test-persistence.cpp +++ b/test/test-persistence.cpp @@ -34,6 +34,7 @@ struct JPP { BOOST_FIXTURE_TEST_CASE(load_object, JPP) { auto to = load_json<std::unique_ptr<TestObject>>(FIXTURESDIR "json/load_object.json"); + BOOST_CHECK_EQUAL(to->postLoadCalled, 1); BOOST_CHECK_CLOSE(to->flt, 3.14, 0.01); BOOST_CHECK_EQUAL(to->str, "Lovely string"); BOOST_CHECK_EQUAL(to->bl, true); @@ -69,6 +70,7 @@ BOOST_FIXTURE_TEST_CASE(load_object, JPP) BOOST_FIXTURE_TEST_CASE(load_nested_object, JPP) { auto to = load_json<std::unique_ptr<TestObject>>(FIXTURESDIR "json/nested.json"); + BOOST_CHECK_EQUAL(to->postLoadCalled, 1); BOOST_CHECK_EQUAL(to->flt, 1.F); BOOST_CHECK_EQUAL(to->str, "one"); BOOST_REQUIRE(to->ptr); @@ -86,6 +88,7 @@ BOOST_FIXTURE_TEST_CASE(load_nested_object, JPP) BOOST_FIXTURE_TEST_CASE(load_implicit_object, JPP) { auto to = load_json<std::unique_ptr<TestObject>>(FIXTURESDIR "json/implicit.json"); + BOOST_CHECK_EQUAL(to->postLoadCalled, 1); BOOST_CHECK(to->ptr); BOOST_CHECK_EQUAL(to->flt, 1.F); BOOST_CHECK_EQUAL(to->ptr->str, "trigger"); @@ -95,6 +98,7 @@ BOOST_FIXTURE_TEST_CASE(load_implicit_object, JPP) BOOST_FIXTURE_TEST_CASE(load_empty_object, JPP) { auto to = load_json<std::unique_ptr<TestObject>>(FIXTURESDIR "json/empty.json"); + BOOST_CHECK_EQUAL(to->postLoadCalled, 1); BOOST_CHECK_EQUAL(to->flt, 1.F); BOOST_CHECK(to->ptr); BOOST_CHECK_EQUAL(to->str, "after"); @@ -119,6 +123,7 @@ BOOST_FIXTURE_TEST_CASE(load_obj_no_such_type, JPP) BOOST_FIXTURE_TEST_CASE(load_abs_object, JPP) { auto to = load_json<std::unique_ptr<TestObject>>(FIXTURESDIR "json/abs.json"); + BOOST_CHECK_EQUAL(to->postLoadCalled, 1); BOOST_REQUIRE(to->aptr); BOOST_CHECK_NO_THROW(to->aptr->dummy()); BOOST_CHECK_EQUAL(to->aptr->base, "set base"); @@ -130,6 +135,7 @@ BOOST_FIXTURE_TEST_CASE(load_abs_object, JPP) BOOST_FIXTURE_TEST_CASE(load_vector_ptr, JPP) { auto to = load_json<std::unique_ptr<TestObject>>(FIXTURESDIR "json/vector_ptr.json"); + BOOST_CHECK_EQUAL(to->postLoadCalled, 1); BOOST_CHECK(to->str.empty()); BOOST_CHECK_EQUAL(to->vptr.size(), 4); BOOST_CHECK_EQUAL(to->vptr.at(0)->str, "type"); @@ -141,6 +147,7 @@ BOOST_FIXTURE_TEST_CASE(load_vector_ptr, JPP) BOOST_FIXTURE_TEST_CASE(test_conversion, JPP) { auto to = load_json<std::unique_ptr<TestObject>>(FIXTURESDIR "json/conv.json"); + BOOST_CHECK_EQUAL(to->postLoadCalled, 1); BOOST_REQUIRE(to); BOOST_CHECK_EQUAL(to->bl, true); BOOST_CHECK_EQUAL(to->flt, 3.14F); diff --git a/test/testStructures.cpp b/test/testStructures.cpp index 8305078..469ec37 100644 --- a/test/testStructures.cpp +++ b/test/testStructures.cpp @@ -42,6 +42,12 @@ TestObject::persist(Persistence::PersistenceStore & store) && STORE_MEMBER(vptr); } +void +TestObject::postLoad() +{ + postLoadCalled++; +} + bool SharedTestObject::persist(Persistence::PersistenceStore & store) { diff --git a/test/testStructures.h b/test/testStructures.h index 666562e..6966052 100644 --- a/test/testStructures.h +++ b/test/testStructures.h @@ -39,7 +39,10 @@ struct TestObject : public Persistence::Persistable { std::unique_ptr<AbsObject> aptr; std::vector<std::unique_ptr<TestObject>> vptr; + unsigned int postLoadCalled {}; + bool persist(Persistence::PersistenceStore & store) override; + void postLoad() override; }; struct SharedTestObject : public Persistence::Persistable { |