X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestDataEntry.cxx;h=05755d35b1599d2eff7e97d87e808a574553c890;hb=HEAD;hp=b0611b937cd31fd8f19849d8adcdee56a61b19aa;hpb=9dbffd306a2b7981cf033ab8402c774f8f970475;p=gdcm.git diff --git a/Testing/TestDataEntry.cxx b/Testing/TestDataEntry.cxx index b0611b93..05755d35 100644 --- a/Testing/TestDataEntry.cxx +++ b/Testing/TestDataEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDataEntry.cxx,v $ Language: C++ - Date: $Date: 2005/10/23 19:52:37 $ - Version: $Revision: 1.7 $ + Date: $Date: 2008/09/15 15:49:21 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -30,24 +30,31 @@ const float fvalue[]={1.1f,2.2f,3.3f,4.4f,5.5f}; const double dvalue[]={1.1,2.2,3.3,4.4,5.5}; const unsigned long nbvalue = 5; -const float GDCM_EPS = 1e-6; +const double GDCM_EPS = 1e-6; /** * \brief Test the DataEntry object */ int TestDataEntry(int , char *[]) { + /* Most of the tests are out of date! + (we don't use any longer DictEntry to build a DocEntry! + unsigned int i; - gdcm::DictEntry *dict; - gdcm::DataEntry *entry; - - //------------------------------------------------------------------ - dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); - dict->SetVR("US"); + GDCM_NAME_SPACE::DictEntry *dict; + GDCM_NAME_SPACE::DataEntry *entry; + + dict = GDCM_NAME_SPACE::DictEntry::New(0x0003,0x0004); + // SetVR *before* making the DataEntry! + dict->SetVR("US"); + entry = GDCM_NAME_SPACE::DataEntry::New(dict); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; + std::cout << "TagKey : [" << entry->GetKey() << "]" << std::endl; + std::cout << "Group : [" << entry->GetGroup() << "]" << std::endl; + std::cout << "Element : [" << entry->GetElement() << "]" << std::endl; + entry->SetString("1"); std::cout << "1: "; entry->Print(std::cout); @@ -59,7 +66,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 1" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } @@ -74,7 +81,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 2" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } @@ -89,18 +96,19 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 0" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ - dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + dict = GDCM_NAME_SPACE::DictEntry::New(0x0000,0x0000); + // SetVR *before* making the DataEntry! dict->SetVR("LT"); + entry = GDCM_NAME_SPACE::DataEntry::New(dict); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; entry->SetString(data); @@ -114,7 +122,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << strlen(data) + strlen(data)%2 << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -124,7 +132,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetBinArea(),data,entry->GetLength()) != 0 ) @@ -132,7 +140,7 @@ int TestDataEntry(int , char *[]) std::cout << " Failed" << std::endl << " Content of bin area is incorrect" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),data,entry->GetLength()) != 0 ) @@ -142,7 +150,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -154,19 +162,21 @@ int TestDataEntry(int , char *[]) << " Found " << entry->GetValue(i) << " - Must be " << svalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ - dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + dict = GDCM_NAME_SPACE::DictEntry::New(0x0000,0x0000); + // SetVR *before* making the DataEntry! dict->SetVR("US"); + entry = GDCM_NAME_SPACE::DataEntry::New(dict); + std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; entry->SetString(data); @@ -181,7 +191,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(uint16_t) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 ) @@ -191,7 +201,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -201,7 +211,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -213,7 +223,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << svalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -231,7 +241,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -241,7 +251,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -253,19 +263,19 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << svalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ - dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + dict = GDCM_NAME_SPACE::DictEntry::New(0x0000,0x0000); dict->SetVR("UL"); + entry = GDCM_NAME_SPACE::DataEntry::New(dict); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; entry->SetString(data); @@ -280,7 +290,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(uint32_t) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 ) @@ -290,7 +300,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -300,7 +310,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -312,7 +322,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << lvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -330,7 +340,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -340,7 +350,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -352,19 +362,19 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << lvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ - dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + dict = GDCM_NAME_SPACE::DictEntry::New(0x0000,0x0000); dict->SetVR("FL"); + entry = GDCM_NAME_SPACE::DataEntry::New(dict); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; entry->SetString(fdata); @@ -379,7 +389,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(float) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 ) @@ -389,7 +399,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -399,7 +409,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -411,7 +421,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << fvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -429,7 +439,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -439,7 +449,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -451,19 +461,19 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << fvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ - dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + dict = GDCM_NAME_SPACE::DictEntry::New(0x0000,0x0000); dict->SetVR("FD"); + entry = GDCM_NAME_SPACE::DataEntry::New(dict); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; entry->SetString(fdata); @@ -478,7 +488,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(double) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 ) @@ -488,7 +498,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -498,7 +508,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -512,7 +522,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << dvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -530,7 +540,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -540,7 +550,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -552,16 +562,17 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << dvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ std::cout<