From cc2524203927d4dba88a87b667c0e235b081cb3a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 9 Jul 2017 14:03:48 +0100 Subject: Refactor test options class into its own lib --- icetray/unittests/Jamfile.jam | 8 ++++++++ icetray/unittests/testIceTrayOptions.cpp | 20 +------------------- icetray/unittests/testOptions.cpp | 14 ++++++++++++++ icetray/unittests/testOptions.h | 18 ++++++++++++++++++ 4 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 icetray/unittests/testOptions.cpp create mode 100644 icetray/unittests/testOptions.h diff --git a/icetray/unittests/Jamfile.jam b/icetray/unittests/Jamfile.jam index 2b44a74..ee2c429 100644 --- a/icetray/unittests/Jamfile.jam +++ b/icetray/unittests/Jamfile.jam @@ -89,10 +89,18 @@ run testCommon ; +lib testOptions + : + testOptions.cpp + : : + testCommon + ; + run testIceTrayOptions.cpp : : : testCommon + testOptions ; IMPORT $(__name__) : icetray.c++.sql : : icetray.c++.sql ; diff --git a/icetray/unittests/testIceTrayOptions.cpp b/icetray/unittests/testIceTrayOptions.cpp index 2c56537..a8fe157 100644 --- a/icetray/unittests/testIceTrayOptions.cpp +++ b/icetray/unittests/testIceTrayOptions.cpp @@ -1,30 +1,12 @@ #define BOOST_TEST_MODULE TestIceTrayLogger #include -#include +#include "testOptions.h" #include #include #include #include "icetrayService.h" -class TestOptions : public IceTray::Options { - public: - TestOptions() : IceTray::Options("Test options") - { - } - - ICETRAY_OPTIONS_INLINE( - ("testInt", boost::program_options::value(&testInt), "testInt") - ("testString", boost::program_options::value(&testString)->default_value("some string"), "testString") - ("vec", boost::program_options::value(&testVec), "vector") - ); - - int testInt; - std::string testString; - std::vector testVec; -}; -FACTORY(TestOptions, IceTray::OptionsFactory); - class TestService : public IceTray::Service { public: void addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &) diff --git a/icetray/unittests/testOptions.cpp b/icetray/unittests/testOptions.cpp new file mode 100644 index 0000000..b0bfdee --- /dev/null +++ b/icetray/unittests/testOptions.cpp @@ -0,0 +1,14 @@ +#include "testOptions.h" + +TestOptions::TestOptions() : IceTray::Options("Test options") +{ +} + +ICETRAY_OPTIONS(TestOptions, + ("testInt", boost::program_options::value(&testInt), "testInt") + ("testString", boost::program_options::value(&testString)->default_value("some string"), "testString") + ("vec", boost::program_options::value(&testVec), "vector") +); + +FACTORY(TestOptions, IceTray::OptionsFactory); + diff --git a/icetray/unittests/testOptions.h b/icetray/unittests/testOptions.h new file mode 100644 index 0000000..06adb19 --- /dev/null +++ b/icetray/unittests/testOptions.h @@ -0,0 +1,18 @@ +#ifndef ICETRAY_TEST_TESTOPTIONS_H +#define ICETRAY_TEST_TESTOPTIONS_H + +#include + +class DLL_PUBLIC TestOptions : public IceTray::Options { + public: + TestOptions(); + + ICETRAY_OPTIONS_DECLARE; + + int testInt; + std::string testString; + std::vector testVec; +}; + +#endif + -- cgit v1.2.3