]> 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 10:43:19 $
7   Version:   $Revision: 1.8 $
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 <iostream>
23
24 int TestUtil(int , char * [])
25 {
26    // Time 
27    std::cout << "Time:" << gdcm::Util::GetCurrentDateTime() << std::endl;
28
29    // Processor ID
30    unsigned int processorID;;
31    processorID = gdcm::Util::GetCurrentProcessID();
32    std::cout << "Current Processor ID " <<  processorID << std::endl;
33
34    // MAC Adress
35    std::cout << "Mac Address:" << gdcm::Util::GetMACAddress() << std::endl;
36
37    // Unique UID test
38    std::string gdcmUid;
39    for (int i=0; i<10; i++)
40    {
41       gdcmUid = gdcm::Util::CreateUniqueUID();
42       std::cout << "Current UID for gdcm " <<  gdcmUid << std::endl;
43    }
44    
45    // DicomString test
46    const char ref[] = "MONOCHROME1";
47    std::string a = "MONOCHROME1";
48    a += '\0';
49    std::string b = "MONOCHROME1 ";
50    std::string c = gdcm::Util::DicomString("MONOCHROME1");
51    std::string d = "MONOCHROME1";
52
53    if( !gdcm::Util::DicomStringEqual(a,ref) ) 
54       return 1;
55    if( !gdcm::Util::DicomStringEqual(b,ref) ) 
56       return 1;
57    if( !gdcm::Util::DicomStringEqual(c,ref) ) 
58       return 1;
59    if(  gdcm::Util::DicomStringEqual(d,ref) ) 
60       return 1;
61
62    return 0;
63 }