]> Creatis software - gdcm.git/blob - Testing/TestHash.cxx
Fix mistypings
[gdcm.git] / Testing / TestHash.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestHash.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/02/02 10:05:26 $
7   Version:   $Revision: 1.17 $
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 "gdcmCommon.h" //to shut up warnings
19 // Checks the basic functionalities of STL <map>.
20 #include <map>
21 #include <string>
22 #include <iostream>
23
24 int TestHash( int, char *[] )
25 {
26    std::cout << "Test::TestHash : " << std::endl;
27    std::cout << "   Checks that the basic STL <map> functionalities required "
28              << std::endl
29              << "   by gdcm are operational. " << std::endl;
30
31    typedef std::map<std::string, std::string> dict;
32    dict tb1;
33
34    // Adding entries by key:
35
36    dict::iterator im = tb1.find("00380010");
37    tb1["00100010"] = "Patient Name";
38    tb1["7fe00010"] = "Pixel Data";
39    tb1["50000010"] = "Number of points";
40    tb1["00380010"] = "Admission ID";
41
42    // Travesing the dictionary:
43
44    std::cout << "   Traversal of dictionary (note the proper ordering on key):"
45              << std::endl;
46    for ( im = tb1.begin(); im != tb1.end(); ++im )
47       std::cout << "       \"" << im->first << "\" = " << im->second
48                 << std::endl;
49    std::cout << "   End of dictionary." << std::endl;
50
51    // Find request.
52
53    std::cout << "   Find request on key 00380010" << std::endl;
54    im = tb1.find("00380010");
55    std::cout << "       \"" << im->first << "\" = " << im->second << std::endl;
56
57    // The following should print in hexadecimal an in decimal the given
58    // integer as stated by:
59    //   http://www.developer.com/net/cplus/article.php/10919_2119781_3
60    // Alas it doesn't work with g++ (at least)...
61    int i = 0x0010;
62    //std::cout.setf(std::ios::hex);
63    std::cout << "Test::TestHash : hexdecimal output : " << std::hex << i << std::endl;
64    //std::cout.setf(std::ios::dec);
65    std::cout << "Test::TestHash : decimal output : "    << std::dec << i << std::endl;
66
67    return 0;
68 }