]> Creatis software - gdcm.git/blob - Testing/TestUtil.cxx
Test Coverage
[gdcm.git] / Testing / TestUtil.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestUtil.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/27 12:02:26 $
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 // This test should test everything in Util, since I didn't know any other 
19 // way to test this class.
20
21 #include "gdcmUtil.h"
22 #include "gdcmDebug.h"
23 #include <iostream>
24
25 int TestUtil(int , char * [])
26 {
27    // Time 
28    std::cout << "Time:" << gdcm::Util::GetCurrentDateTime() << std::endl;
29
30    // Processor ID
31    unsigned int processorID;;
32    processorID = gdcm::Util::GetCurrentProcessID();
33    std::cout << "Current Processor ID " <<  processorID << std::endl;
34
35    // MAC Adress
36    std::cout << "Mac Address:" << gdcm::Util::GetMACAddress() << std::endl;
37
38    // Unique UID test
39    std::string gdcmUid;
40    for (int i=0; i<10; i++)
41    {
42       gdcmUid = gdcm::Util::CreateUniqueUID();
43       std::cout << "Current UID for gdcm " <<  gdcmUid << std::endl;
44    }
45    
46    // DicomString test
47    const char ref[] = "MONOCHROME1";
48    std::string a = "MONOCHROME1";
49    a += '\0';
50    std::string b = "MONOCHROME1 ";
51    std::string c = gdcm::Util::DicomString("MONOCHROME1");
52    std::string d = "MONOCHROME1";
53
54    if( !gdcm::Util::DicomStringEqual(a,ref) ) 
55       return 1;
56    if( !gdcm::Util::DicomStringEqual(b,ref) ) 
57       return 1;
58    if( !gdcm::Util::DicomStringEqual(c,ref) ) 
59       return 1;
60    if(  gdcm::Util::DicomStringEqual(d,ref) ) 
61       return 1;
62
63 // ----------------------------------------------------------
64 // Let's test gdcm::Debug, now.
65     std::cout << "GetDebugFlag : " << gdcm::Debug::GetDebugFlag() <<std::endl;
66     gdcm::Debug::SetDebugFilename ("DummyFileNameToWriteTo.txt");
67     std::cout << "We set a Debug file"   <<std::endl;
68     if ( !gdcm::Debug::GetDebugFlag() )
69     {
70        std::cout << "Debug Flag should be TRUE... " << std::endl;
71        return 1;
72     }
73     std::cout << "GetDebugFlag : " << gdcm::Debug::GetDebugFlag()<<std::endl;
74     gdcm::Debug::SetDebugFlag ( false );
75     std::cout << "GetDebugFlag : " << gdcm::Debug::GetDebugFlag()<<std::endl;
76     gdcm::Debug::SetDebugFilename ("DummyFileNameToWriteTo2.txt");    
77
78    return 0;
79 }