My Project
plugintester.hh
Go to the documentation of this file.
1/* -*- mia-c++ -*-
2 *
3 * This file is part of MIA - a toolbox for medical image analysis
4 * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5 *
6 * MIA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
25#include <climits>
26
27#ifndef BOOST_TEST_DYN_LINK
28#define BOOST_TEST_DYN_LINK
29#endif
30
31#define BOOST_TEST_MAIN
32#define BOOST_TEST_NO_MAIN
33#include <boost/test/unit_test.hpp>
34#include <boost/test/tools/floating_point_comparison.hpp>
35
36#include <miaconfig.h>
37#include <mia/core/factory.hh>
40#include <mia/internal/main.hh>
41
43
44template <typename Plugin>
45typename Plugin::UniqueProduct BOOST_TEST_create_from_plugin(const char *param)
46{
47 assert(param);
48 Plugin plugin;
49 CComplexOptionParser param_list(param);
50 BOOST_REQUIRE(param_list.size() > 0);
51 BOOST_CHECK_EQUAL(plugin.get_name(), param_list.begin()->first);
52 return typename Plugin::UniqueProduct(plugin.create(param_list.begin()->second, param));
53}
54
55
57
58
60 {mia::pdi_group, "Test"},
61 {mia::pdi_short, "Unit test for a plug-in."},
62 {mia::pdi_description, "This program runs a set of tests."},
63 {mia::pdi_example_descr, "Example text"},
65};
66
67int BOOST_TEST_CALL_DECL
68do_main( int argc, char *argv[] )
69{
70 mia::PrepareTestPluginPath prepare_plugin_path;
71#ifdef WIN32
72 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
73 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
74#endif
75
76 if (mia::CCmdOptionList(description).parse(argc, argv, "boost-test-option") != mia::CCmdOptionList::hr_no)
77 return 0;
78
79 mia::cvdebug() << "Initialize test ...\n";
80 return ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
81}
82
Parser for complex command line options.
Definition: optionparser.hh:56
const_iterator begin() const
CParts::size_type size() const
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
std::map< EProgramDescriptionEntry, const char * > SProgramDescription
the map that holds a basic program description
@ pdi_example_descr
@ pdi_example_code
@ pdi_short
@ pdi_description
@ pdi_group
CDebugSink & cvdebug()
Definition: msgstream.hh:226
int BOOST_TEST_CALL_DECL do_main(int argc, char *argv[])
Definition: plugintester.hh:68
Plugin::UniqueProduct BOOST_TEST_create_from_plugin(const char *param)
Definition: plugintester.hh:45
MIA_MAIN(do_main)
const mia::SProgramDescription description
Definition: plugintester.hh:59