From 07fe39635688899a1a08cf1084446dc31f251d15 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Fri, 19 Dec 2025 11:30:39 -0800 Subject: [PATCH] container: root: test: unit: utility: add/update macro cases --- container/src/root/test/unit/utility.hh | 43 +++++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/container/src/root/test/unit/utility.hh b/container/src/root/test/unit/utility.hh index 2ea45fa..0981cea 100644 --- a/container/src/root/test/unit/utility.hh +++ b/container/src/root/test/unit/utility.hh @@ -867,22 +867,51 @@ struct MacroFreeFiles : public ::testing::Test, { }; -TEST_F(MacroFreeFiles, LoadSingle) +TEST_F(MacroFreeFiles, LoadUnloadSingleSimple) { ASSERT_THROW( - ::dfi::macro::load("macro/should-not/exist.C"), + ::dfi::macro::load("repo/should-not/exist.C"), common::type::RuntimeError); ASSERT_THROW( common::line("dfi::macro::common::crypto::botan::Hash h;"), common::type::RuntimeError); - // TODO(afiore): macro loading should not need to be prepended with "macro/" - // (see TODO in common impl regarding plugins-like functionality) - ASSERT_NO_THROW(::dfi::macro::load("macro/crypto/hash.C")); + ASSERT_NO_THROW(::dfi::macro::load("repo/crypto/hash.C")); ASSERT_NO_THROW(common::line("dfi::macro::common::crypto::botan::Hash h;")); + + ASSERT_NO_THROW(::dfi::macro::unload("repo/crypto/hash.C")); + ASSERT_THROW( + common::line("dfi::macro::common::crypto::botan::Hash h;"), + common::type::RuntimeError); } -// TODO(afiore): multiple load -// TODO(afiore): unload, reload + +TEST_F(MacroFreeFiles, LoadUnloadMultipleSimple) +{ + ASSERT_THROW( + common::line("dfi::macro::common::crypto::botan::Hash h;"), + common::type::RuntimeError); + + ASSERT_THROW( + common::line("dfi::macro::common::crypto::libsodium::Random r;"), + common::type::RuntimeError); + + ASSERT_NO_THROW( + ::dfi::macro::load({"repo/crypto/hash.C", "repo/crypto/random.C"})); + ASSERT_NO_THROW(common::line("dfi::macro::common::crypto::botan::Hash h;")); + ASSERT_NO_THROW( + common::line("dfi::macro::common::crypto::libsodium::Random r;")); + + ASSERT_NO_THROW( + ::dfi::macro::unload({"repo/crypto/random.C", "repo/crypto/hash.C"})); + ASSERT_THROW( + common::line("dfi::macro::common::crypto::libsodium::Random r;"), + common::type::RuntimeError); + ASSERT_THROW( + common::line("dfi::macro::common::crypto::botan::Hash h;"), + common::type::RuntimeError); +} +// TODO(afiore): load/unload w/ Pluggable types +// TODO(afiore): reload //! \brief Plugin command fixture for testing auto-(un|re)loading functionality //! \details Will test loading/unloading/reloading and argument passing to plugin