diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-08-05 21:12:44 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-08-06 09:29:23 +0200 |
commit | f016f9016f5139791d544b5e5aa2ac438227b735 (patch) | |
tree | 265f38567c6870252aa7bed6f709ee334b640600 /include/unotest | |
parent | loplugin:flatten in unoxml (diff) | |
download | core-f016f9016f5139791d544b5e5aa2ac438227b735.tar.gz core-f016f9016f5139791d544b5e5aa2ac438227b735.zip |
unotest: one Resetter is enough
It seems all 3 places derive from unotest::MacrosTest, so extract the
common code there.
Change-Id: I71a2474a7d6b1623f50575f9e9c43580ba076330
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100185
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'include/unotest')
-rw-r--r-- | include/unotest/macros_test.hxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx index 2960dc0fbb23..6f55e34e7c87 100644 --- a/include/unotest/macros_test.hxx +++ b/include/unotest/macros_test.hxx @@ -13,6 +13,7 @@ #include <sal/config.h> #include <memory> +#include <functional> #include <config_gpgme.h> #include <rtl/ustring.hxx> #include <unotest/detail/unotestdllapi.hxx> @@ -38,6 +39,30 @@ namespace unotest { class OOO_DLLPUBLIC_UNOTEST MacrosTest { public: + class Resetter + { + private: + std::function<void ()> m_Func; + + public: + Resetter(std::function<void ()> const& rFunc) + : m_Func(rFunc) + { + } + ~Resetter() + { + try + { + m_Func(); + } + catch (...) // has to be reliable + { + fprintf(stderr, "resetter failed with exception\n"); + abort(); + } + } + }; + MacrosTest(); ~MacrosTest(); |