]> Creatis software - gdcm.git/blob - Testing/TestVR.cxx
ENH: Add a very bizarre case
[gdcm.git] / Testing / TestVR.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestVR.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/10/20 15:05:15 $
7   Version:   $Revision: 1.9 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html 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 #include "gdcmVR.h"
19
20 int TestVR(int , char *[])
21 {
22    int error = 0;
23    gdcm::VR *vr = new gdcm::VR();
24  
25    // There should be 16 entries ...
26    vr->Print( std::cout );
27
28    // Valid VR
29    if( !vr->IsValidVR( "PN" ) )
30    {
31       std::cerr << "'PN' is not a valid VR" << std::endl;
32       error++;
33    }
34    if( !vr->IsValidVR( "FD" ) )
35    {
36       std::cerr << "'FD' is not a valid VR" << std::endl;
37       error++;
38    }
39    if( vr->IsValidVR( "" ) )
40    {
41       std::cerr << "'' is a valid VR" << std::endl;
42       error++;
43    }
44    if( vr->IsValidVR( "  " ) )
45    {
46       std::cerr << "'  ' is a valid VR" << std::endl;
47       error++;
48    }
49    if( vr->IsValidVR( "\000/" ) )
50    {
51       std::cerr << "'\000/' is a valid VR" << std::endl;
52       error++;
53    }
54    if( vr->IsValidVR( gdcm::GDCM_VRUNKNOWN ) )
55    {
56       std::cerr << "'  ' is a valid VR" << std::endl;
57       error++;
58    }
59
60    // String representable
61    if( !vr->IsVROfStringRepresentable( "PN" ) )
62    {
63       std::cerr << "'PN' is not a string representable" << std::endl;
64       error++;
65    }
66    if( vr->IsVROfStringRepresentable( "FD" ) )
67    {
68       std::cerr << "'FD' is a string representable" << std::endl;
69       error++;
70    }
71
72    // Binary representable
73    if( !vr->IsVROfBinaryRepresentable( "FD" ) )
74    {
75       std::cerr << "FD is not a binary representable" << std::endl;
76       error++;
77    }
78    if( vr->IsVROfBinaryRepresentable( "PN" ) )
79    {
80       std::cerr << "'PN' is a binary representable" << std::endl;
81       error++;
82    }
83
84    // Sequence
85    if( vr->IsVROfSequence( "" ) )
86    {
87       std::cerr << "'' is a sequence" << std::endl;
88       error++;
89    }
90    if( !vr->IsVROfSequence( "SQ" ) )
91    {
92       std::cerr << "'SQ' is not a sequence" << std::endl;
93       error++;
94    }
95
96    delete vr;
97    return error;
98 }