~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Testing/Code/IO/itkImageIOBaseTest.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-12-19 20:16:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081219201649-drt97guwl2ryt0cn

* New upstream version.
  - patches/nifti-versioning.patch: Remove.  Applied upstream.
  - control:
  - rules: Update version numbers, package names.

* control: Build-depend on uuid-dev (gdcm uses it).

* copyright: Update download URL.

* rules: Adhere to parallel=N in DEB_BUILD_OPTIONS by setting MAKEFLAGS.

* compat: Set to 7.
* control: Update build-dep on debhelper to version >= 7.

* CMakeCache.txt.debian: Set CMAKE_BUILD_TYPE to "RELEASE" so that we
  build with -O3 (not -O2), necessary to optimize the templated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Insight Segmentation & Registration Toolkit
 
4
  Module:    $RCSfile: itkImageIOBaseTest.cxx,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2008-05-27 12:07:34 $xgoto-l
 
7
 
 
8
  Version:   $Revision: 1.3 $
 
9
 
 
10
  Copyright (c) 2002 Insight Consortium. All rights reserved.
 
11
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
 
12
 
 
13
     This software is distributed WITHOUT ANY WARRANTY; without even 
 
14
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
15
     PURPOSE.  See the above copyright notices for more information.
 
16
 
 
17
=========================================================================*/
 
18
#if defined(_MSC_VER)
 
19
#pragma warning ( disable : 4786 )
 
20
#endif
 
21
#include "itkImageIOBase.h"
 
22
#include "itkMetaImageIO.h"
 
23
 
 
24
int itkImageIOBaseTest( int , char * [] )
 
25
{
 
26
  typedef itk::ImageIOBase                 BaseReaderType;
 
27
  typedef BaseReaderType                   BaseReaderPointerType;
 
28
 
 
29
  typedef itk::MetaImageIO                 ReaderType;
 
30
  typedef ReaderType::Pointer              ReaderPointerType;
 
31
 
 
32
  itk::MetaImageIO::Pointer reader = itk::MetaImageIO::New();
 
33
  reader->SetNumberOfDimensions(3);
 
34
 
 
35
  bool gotException = false;
 
36
  try 
 
37
    {
 
38
    reader->SetDimensions(3,1);
 
39
    }
 
40
  catch ( itk::ExceptionObject& e )
 
41
    {
 
42
    std::cerr << "Caught expected exception " << e << std::endl;
 
43
    gotException = true;
 
44
    }
 
45
  if (!gotException)
 
46
    {
 
47
    std::cerr << "Failed to catch expected exception in method SetDimensions"
 
48
              << std::endl;
 
49
    return EXIT_FAILURE;
 
50
    }
 
51
  
 
52
  gotException = false;
 
53
  try 
 
54
    {
 
55
    reader->SetOrigin(3,1.0);
 
56
    }
 
57
  catch ( itk::ExceptionObject& e )
 
58
    {
 
59
    std::cerr << "Caught expected exception " << e << std::endl;
 
60
    gotException = true;
 
61
    }
 
62
  if (!gotException)
 
63
    {
 
64
    std::cerr << "Failed to catch expected exception in method SetOrigin"
 
65
              << std::endl;
 
66
    return EXIT_FAILURE;
 
67
    }
 
68
 
 
69
  gotException = false;
 
70
  try 
 
71
    {
 
72
    reader->SetSpacing(3,1.0);
 
73
    }
 
74
  catch ( itk::ExceptionObject& e )
 
75
    {
 
76
    std::cerr << "Caught expected exception " << e << std::endl;
 
77
    gotException = true;
 
78
    }
 
79
  if (!gotException)
 
80
    {
 
81
    std::cerr << "Failed to catch expected exception in method SetSpacing"
 
82
              << std::endl;
 
83
    return EXIT_FAILURE;
 
84
    }
 
85
 
 
86
  gotException = false;
 
87
  try 
 
88
    {
 
89
    std::vector<double> direction(3);
 
90
    direction[0] = 1.0;
 
91
    direction[1] = 1.0;
 
92
    direction[2] = 1.0;
 
93
    reader->SetDirection(3,direction);
 
94
    }
 
95
  catch ( itk::ExceptionObject& e )
 
96
    {
 
97
    std::cerr << "Caught expected exception " << e << std::endl;
 
98
    gotException = true;
 
99
    }
 
100
  if (!gotException)
 
101
    {
 
102
    std::cerr << "Failed to catch expected exception in method SetDirection"
 
103
              << std::endl;
 
104
    return EXIT_FAILURE;
 
105
    }
 
106
 
 
107
  gotException = false;
 
108
  try 
 
109
    {
 
110
    vnl_vector<double> direction(3);
 
111
    direction[0] = 1.0;
 
112
    direction[1] = 1.0;
 
113
    direction[2] = 1.0;
 
114
    reader->SetDirection(3,direction);
 
115
    }
 
116
  catch ( itk::ExceptionObject& e )
 
117
    {
 
118
    std::cerr << "Caught expected exception " << e << std::endl;
 
119
    gotException = true;
 
120
    }
 
121
  if (!gotException)
 
122
    {
 
123
    std::cerr << "Failed to catch expected exception in method SetDirection"
 
124
              << std::endl;
 
125
    return EXIT_FAILURE;
 
126
    }
 
127
 
 
128
  return EXIT_SUCCESS;
 
129
}