From c3ffe4ff704e60b8e8f2173c64c5ac00a2ab6306 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 19 Oct 2020 14:30:48 -0700 Subject: [PATCH] #143: tests: move new test to virtual serialize test --- tests/unit/test_footprinter.cc | 35 ---------------------- tests/unit/test_virtual_serialize.cc | 43 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/tests/unit/test_footprinter.cc b/tests/unit/test_footprinter.cc index 3957720d..0e66a95c 100644 --- a/tests/unit/test_footprinter.cc +++ b/tests/unit/test_footprinter.cc @@ -529,39 +529,4 @@ TEST_F(TestFootprinter, test_virtual_serialize) { } } -struct HolderBase { - checkpoint_virtual_serialize_root() - - virtual ~HolderBase() = default; - - template - void serialize(Serializer& s) {} -}; - -template -struct HolderObjBase : HolderBase { - checkpoint_virtual_serialize_derived_from(HolderBase) - - virtual ObjT* get() = 0; - - template - void serialize(Serializer& s) {} -}; - -template -struct HolderBasic final : HolderObjBase { - checkpoint_virtual_serialize_derived_from(HolderObjBase) - - ObjT* get() override { return obj_; } - ObjT* obj_ = nullptr; - - template - void serialize(Serializer& s) {} -}; - -TEST_F(TestFootprinter, test_virtual_serialize_templated) { - std::unique_ptr ptr = std::make_unique>(); - checkpoint::getMemoryFootprint(ptr); -} - }}} // end namespace checkpoint::tests::unit diff --git a/tests/unit/test_virtual_serialize.cc b/tests/unit/test_virtual_serialize.cc index 22a1a9fa..c455fd0c 100644 --- a/tests/unit/test_virtual_serialize.cc +++ b/tests/unit/test_virtual_serialize.cc @@ -612,4 +612,47 @@ INSTANTIATE_TYPED_TEST_CASE_P( test_virtual_serialize_inst, TestVirtualSerialize, ConstructTypes, ); +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + +// Test for virtual serialize with an abstract class + +using TestVirtualSerializeTemplated = TestHarness; + +struct HolderBase { + checkpoint_virtual_serialize_root() + + virtual ~HolderBase() = default; + + template + void serialize(Serializer& s) {} +}; + +template +struct HolderObjBase : HolderBase { + checkpoint_virtual_serialize_derived_from(HolderBase) + + virtual ObjT* get() = 0; + + template + void serialize(Serializer& s) {} +}; + +template +struct HolderBasic final : HolderObjBase { + checkpoint_virtual_serialize_derived_from(HolderObjBase) + + ObjT* get() override { return obj_; } + ObjT* obj_ = nullptr; + + template + void serialize(Serializer& s) {} +}; + +TEST_F(TestVirtualSerializeTemplated, test_virtual_serialize_templated) { + std::unique_ptr ptr = std::make_unique>(); + checkpoint::getSize(ptr); +} + }}} // end namespace checkpoint::tests::unit