]> Creatis software - gdcm.git/blob - Testing/TestHash.cxx
ENH: Fix a warning with gcc4: TestHash.cxx:20: warning: deprecated conversion from...
[gdcm.git] / Testing / TestHash.cxx
1 #include "gdcmCommon.h" //to shut up warnings
2 // Checks the basic functionalities of STL <map>.
3 #include <map>
4 #include <string>
5 #include <iostream>
6
7 int TestHash( int, char * [] )
8 {
9    std::cout << "Test::TestHash : " << std::endl;
10    std::cout << "   Checks that the basic STL <map> functionalities required "
11              << std::endl
12              << "   by gdcm are operational. " << std::endl;
13
14    typedef std::map<std::string, std::string> dict;
15    dict tb1;
16
17    // Adding entries by key:
18
19    dict::iterator im = tb1.find("00380010");
20    tb1["00100010"] = "Patient Name";
21    tb1["7fe00010"] = "Pixel Data";
22    tb1["50000010"] = "Number of points";
23    tb1["00380010"] = "Admission ID";
24
25    // Travesing the dictionary:
26
27    std::cout << "   Traversal of dictionary (note the proper ordering on key):"
28              << std::endl;
29    for ( im = tb1.begin(); im != tb1.end(); ++im )
30       std::cout << "       \"" << im->first << "\" = " << im->second
31                 << std::endl;
32    std::cout << "   End of dictionary." << std::endl;
33
34    // Find request.
35
36    std::cout << "   Find request on key 00380010" << std::endl;
37    im = tb1.find("00380010");
38    std::cout << "       \"" << im->first << "\" = " << im->second << std::endl;
39
40    // The following should print in hexadecimal an in decimal the given
41    // integer as stated by:
42    //   http://www.developer.com/net/cplus/article.php/10919_2119781_3
43    // Alas it doesn't work with g++ (at least)...
44    int i = 0x0010;
45    //std::cout.setf(std::ios::hex);
46    std::cout << "Test::TestHash : hexdecimal output : " << std::hex << i << std::endl;
47    //std::cout.setf(std::ios::dec);
48    std::cout << "Test::TestHash : decimal output : "    << std::dec << i << std::endl;
49
50    return 0;
51 }