File: test_simple.cc

package info (click to toggle)
mia 2.4.7-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,332 kB
  • sloc: cpp: 162,690; python: 1,317; sh: 321; xml: 127; makefile: 41; csh: 24; ansic: 9
file content (79 lines) | stat: -rw-r--r-- 2,758 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* -*- mia-c++  -*-
 *
 * This file is part of MIA - a toolbox for medical image analysis
 * Copyright (c) Leipzig, Madrid 1999-2016 Gert Wollny
 *
 * MIA is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MIA; if not, see <http://www.gnu.org/licenses/>.
 *
 */

// the plug-in tester function tests whether a plug-in is created according to the specification
#include <mia/internal/plugintester.hh>

/* the filtertest fnction takes input data in a given data typa and an expected result in the expected data
   type and the filter to be tested.
   A test attribute is also created and it is tested whether the filter properly passed this attribute.
*/
#include <mia/template/filtertest.hh>

// this gives the declaration of the filter to be tested
#include <mia/2d/filter/simple.hh>


NS_MIA_USE
using namespace std;
using namespace simple_2dimage_filter;

/*
  The first test checks whether the filter actually throws if the input data is of an unsupported pixel type.
*/


BOOST_FIXTURE_TEST_CASE(test_simple_1, TFiltertestFixture<T2DImage>)
{
       const int src[6] =   {  0,   1,  2,  3,  4,  5};
       const int test[6] =  {  0,  -1, -2, -3, -4, -5};
       C2DBounds size(3, 2);
       C2DSIImage input(size, src);
       auto filter = BOOST_TEST_create_from_plugin<C2DSimpleImageFilterPlugin>("simple:a=-1");
       BOOST_CHECK_THROW(run(size, src, size, test, *filter), invalid_argument);
}


/*
  This test runs a valid filter.
*/

BOOST_FIXTURE_TEST_CASE(test_simple_3, TFiltertestFixture<T2DImage>)
{
       const float src[6] =   {  0,  1,  2,  3,  4,  5};
       const float test[6] =  {  0,  2,  4,  6,  8, 10};
       C2DBounds size(3, 2);
       auto filter = BOOST_TEST_create_from_plugin<C2DSimpleImageFilterPlugin>("simple:a=2");
       run(size, src, size, test, *filter);
}

/*
  This test runs another valid filter with different filter parameters.
*/

BOOST_FIXTURE_TEST_CASE(test_simple_2, TFiltertestFixture<T2DImage>)
{
       const double src[6] =   {  0,   1,  2,  3,  4,  5};
       const double test[6] =  {  0,  -1, -2, -3, -4, -5};
       C2DBounds size(3, 2);
       auto filter = BOOST_TEST_create_from_plugin<C2DSimpleImageFilterPlugin>("simple:a=-1");
       run(size, src, size, test, *filter);
}