]> Creatis software - gdcm.git/blob - Testing/TestVR.cxx
* Some classes inherit now from gdcm::RefCounter
[gdcm.git] / Testing / TestVR.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestVR.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/10/25 14:52:31 $
7   Version:   $Revision: 1.11 $
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 #include "gdcmDebug.h"
20
21 int TestVR(int , char *[])
22 {
23    int error = 0;
24    gdcm::VR *vr = gdcm::VR::New();
25  
26    gdcm::Debug::DebugOn();
27
28    // There should be 16 entries ...
29    vr->Print( std::cout );
30
31    // Valid VR
32    if( !vr->IsValidVR( "PN" ) )
33    {
34       std::cerr << "'PN' is not a valid VR" << std::endl;
35       error++;
36    }
37    if( !vr->IsValidVR( "FD" ) )
38    {
39       std::cerr << "'FD' is not a valid VR" << std::endl;
40       error++;
41    }
42    if( vr->IsValidVR( "" ) )
43    {
44       std::cerr << "'' is a valid VR" << std::endl;
45       error++;
46    }
47    if( vr->IsValidVR( "  " ) )
48    {
49       std::cerr << "'  ' is a valid VR" << std::endl;
50       error++;
51    }
52    if( vr->IsValidVR( "\000/" ) )
53    {
54       std::cerr << "' /' is a valid VR" << std::endl;
55       error++;
56    }
57    if( vr->IsValidVR( gdcm::GDCM_VRUNKNOWN ) )
58    {
59       std::cerr << "'  ' is a valid VR" << std::endl;
60       error++;
61    }
62
63    // String representable
64    if( !vr->IsVROfStringRepresentable( "PN" ) )
65    {
66       std::cerr << "'PN' is not a string representable" << std::endl;
67       error++;
68    }
69    if( vr->IsVROfStringRepresentable( "FD" ) )
70    {
71       std::cerr << "'FD' is a string representable" << std::endl;
72       error++;
73    }
74
75    // Binary representable
76    if( !vr->IsVROfBinaryRepresentable( "FD" ) )
77    {
78       std::cerr << "FD is not a binary representable" << std::endl;
79       error++;
80    }
81    if( vr->IsVROfBinaryRepresentable( "PN" ) )
82    {
83       std::cerr << "'PN' is a binary representable" << std::endl;
84       error++;
85    }
86
87    // Sequence
88    if( vr->IsVROfSequence( "" ) )
89    {
90       std::cerr << "'' is a sequence" << std::endl;
91       error++;
92    }
93    if( !vr->IsVROfSequence( "SQ" ) )
94    {
95       std::cerr << "'SQ' is not a sequence" << std::endl;
96       error++;
97    }
98
99    vr->Delete();
100    return error;
101 }