]> Creatis software - gdcm.git/blob - Testing/TestUtil.cxx
ENH: Add test for GetCurrentDateTime. The two calls show a difference of one millisec...
[gdcm.git] / Testing / TestUtil.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestUtil.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/21 16:07:54 $
7   Version:   $Revision: 1.7 $
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    std::cout << "Time:" << gdcm::Util::GetCurrentDateTime() << std::endl;
27    // Unique UID test
28    std::cout << gdcm::Util::CreateUniqueUID("") << std::endl;
29    
30    // DicomString test
31    const char ref[] = "MONOCHROME1";
32    std::string a = "MONOCHROME1";
33    a += '\0';
34    std::string b = "MONOCHROME1 ";
35    std::string c = gdcm::Util::DicomString("MONOCHROME1");
36    std::string d = "MONOCHROME1";
37
38    if( !gdcm::Util::DicomStringEqual(a,ref) ) 
39       return 1;
40    if( !gdcm::Util::DicomStringEqual(b,ref) ) 
41       return 1;
42    if( !gdcm::Util::DicomStringEqual(c,ref) ) 
43       return 1;
44    if(  gdcm::Util::DicomStringEqual(d,ref) ) 
45       return 1;
46
47    // MAC Adress
48    std::cout << "Mac Address:" << gdcm::Util::GetMACAddress() << std::endl;
49
50    std::cout << "Time:" << gdcm::Util::GetCurrentDateTime() << std::endl;
51
52    return 0;
53 }