X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestHash.cxx;h=e712e355b616065ed8bc5b19810511fbf542ed77;hb=61573d5dba81e5c8a7ce347adebbb941e6583d77;hp=f8d58bcc32fc129dc854b821f57e5727b8f34229;hpb=70e24c6c61481f9836e26b6b44a9670d92a4f43b;p=gdcm.git diff --git a/Testing/TestHash.cxx b/Testing/TestHash.cxx index f8d58bcc..e712e355 100644 --- a/Testing/TestHash.cxx +++ b/Testing/TestHash.cxx @@ -1,24 +1,51 @@ +#include "gdcmCommon.h" //to shut up warnings +// Checks the basic functionalities of STL . #include #include #include -int main() +int TestHash( int, char * [] ) { - typedef map dict; - - dict current; - dict::iterator im = current.find("00380010"); - current["00100010"] = "Patient Name"; - current["7fe00010"] = "Pixel Data"; - current["50000010"] = "Number of points"; - current["00380010"] = "Admission ID"; - - cout << "Traversal of dictionary (note the proper ordering on key)." << endl; - for ( dict::iterator im = current.begin(); im != current.end(); ++im ) - cout << " \"" << im->first << "\" = " << im->second << endl; - cout << "End of dictionary." << endl; - - cout << "Find request on key 00380010" << endl; - im = current.find("00380010"); - cout << " \"" << im->first << "\" = " << im->second << endl; + std::cout << "Test::TestHash : " << std::endl; + std::cout << " Checks that the basic STL functionalities required " + << std::endl + << " by gdcm are operational. " << std::endl; + + typedef std::map dict; + dict tb1; + + // Adding entries by key: + + dict::iterator im = tb1.find("00380010"); + tb1["00100010"] = "Patient Name"; + tb1["7fe00010"] = "Pixel Data"; + tb1["50000010"] = "Number of points"; + tb1["00380010"] = "Admission ID"; + + // Travesing the dictionary: + + std::cout << " Traversal of dictionary (note the proper ordering on key):" + << std::endl; + for ( im = tb1.begin(); im != tb1.end(); ++im ) + std::cout << " \"" << im->first << "\" = " << im->second + << std::endl; + std::cout << " End of dictionary." << std::endl; + + // Find request. + + std::cout << " Find request on key 00380010" << std::endl; + im = tb1.find("00380010"); + std::cout << " \"" << im->first << "\" = " << im->second << std::endl; + + // The following should print in hexadecimal an in decimal the given + // integer as stated by: + // http://www.developer.com/net/cplus/article.php/10919_2119781_3 + // Alas it doesn't work with g++ (at least)... + int i = 0x0010; + std::cout.setf(std::ios::hex); + std::cout << "Test::TestHash : hexdecimal output : " << i << std::endl; + std::cout.setf(std::ios::dec); + std::cout << "Test::TestHash : decimal output : " << i << std::endl; + + return 0; }