X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestDict.cxx;h=232bbb01d5a9b62051fb7d5304efbe9bc012eada;hb=6c97d504aaac1aa41e9ad2b840863f5229c7515e;hp=cd0601e60d5857a1a51bdc0136d83d67e6562779;hpb=5a0d183707a94e875a595036f64d0bd506faf618;p=gdcm.git diff --git a/Testing/TestDict.cxx b/Testing/TestDict.cxx index cd0601e6..232bbb01 100644 --- a/Testing/TestDict.cxx +++ b/Testing/TestDict.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDict.cxx,v $ Language: C++ - Date: $Date: 2005/01/14 11:28:29 $ - Version: $Revision: 1.1 $ + Date: $Date: 2005/10/20 15:24:05 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,18 +23,48 @@ #include #include -int TestDict(int argc, char* argv[]) -{ +int TestDict(int , char *[]) +{ + + std::cout << "----- Test Default Dicom Dictionary : ----------" << std::endl; + // Just to improve test coverage: + gdcm::Dict *tempDict = new gdcm::Dict("dummyFileNameThatDoesntExist"); + // Default dict is supposed to be used. + tempDict->Print(); + std::cout << "---- end Test Default Dicom Dictionary : -------" << std::endl; + + // Lets delete it. + delete tempDict; + + // Print the DictSet std::cout<<"#######################################################\n"; gdcm::DictSet *dicts=gdcm::Global::GetDicts(); if(!dicts) { - std::cout<<"The DictSet hasn't be found... Failed\n"; + std::cout<<"DictSet hasn't be found... Failed\n"; return(1); } + std::cout<<"DictSet content :\n"; -// dicts->Print(std::cout); + + gdcm::Dict *d = dicts->GetFirstDict(); + if (!d) + { + std::cout << "Dictset is empty" << std::endl; + return 1; + } + + std::cout << "----------- Print DictSet contents: ----------" << std::endl; + dicts->Print(); + std::cout << "----------- End Print DictSet contents: ------" << std::endl; + + while (d) + { + std::cout << "------------- a Dict is found : ----------" << std::endl; + d->Print(); + d = dicts->GetNextDict(); + } // Print the Dict (public) std::cout<<"#######################################################\n"; @@ -45,31 +75,39 @@ int TestDict(int argc, char* argv[]) return(1); } std::cout<<"Public Dict content :\n"; -// pubDict->Print(std::cout); +// pubDict->Print(); // Print the DictEntry (0x10,0x20) std::cout<<"#######################################################\n"; const int ENTRY_GR = 0x10; const int ENTRY_EL = 0x20; - std::string key=gdcm::DictEntry::TranslateToKey(ENTRY_GR,ENTRY_EL); - gdcm::DictEntry *entry=pubDict->GetDictEntry(ENTRY_GR,ENTRY_EL); + gdcm::TagKey key = gdcm::DictEntry::TranslateToKey(ENTRY_GR,ENTRY_EL); + gdcm::DictEntry *entry=pubDict->GetEntry(ENTRY_GR,ENTRY_EL); if(!entry) { std::cout<<"The DictEntry hasn't be found... Failed\n"; return(1); } std::cout<<"Entry "<Print(std::cout); + entry->Print(); // Print all the DictEntry std::cout<<"#######################################################\n"; - pubDict->InitTraversal(); - entry=pubDict->GetNextEntry(); + entry=pubDict->GetFirstEntry(); while(entry) { - entry->Print(std::cout); + std::cout << entry->GetGroup() << "|" << entry->GetElement() + << " [" << entry->GetVR() << "] - M" << entry->GetVM() + << " : " << entry->GetName() << " ( " << entry->GetKey() << ")\n"; entry=pubDict->GetNextEntry(); } + // Let's play with DicEntry stuff ! + + // First, we try to break an Entry. + entry=pubDict->GetFirstEntry(); + entry->SetVR("PN"); + // Should warn us ! + return(0); }