X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestDataEntry.cxx;h=f0dc13f594b48e4c9727e351684bdaff91a08e53;hb=c64b728232bfd4b8455a578f9efb50bd61f88c87;hp=ebd4892feac192eb7ec2ac27fd3142b57c801c91;hpb=692c278613503559a7e64e475374f3e06f6da257;p=gdcm.git diff --git a/Testing/TestDataEntry.cxx b/Testing/TestDataEntry.cxx index ebd4892f..f0dc13f5 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:46:17 $ - Version: $Revision: 1.6 $ + Date: $Date: 2005/10/24 16:00:46 $ + 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 @@ -27,15 +27,10 @@ const char fdata[] = "1.1\\2.2\\3.3\\4.4\\5.5"; const int16_t svalue[]={1,2,3,4,5}; const int32_t lvalue[]={1,2,3,4,5}; const float fvalue[]={1.1f,2.2f,3.3f,4.4f,5.5f}; -// Temporary hack, assume that long and double are correlated -#if GDCM_SIZEOF_LONG == 4 const double dvalue[]={1.1,2.2,3.3,4.4,5.5}; -#else -const float dvalue[]={1.1,2.2,3.3,4.4,5.5}; -#endif const unsigned long nbvalue = 5; -const float GDCM_EPS = 1e-6; +const double GDCM_EPS = 1e-6; /** * \brief Test the DataEntry object @@ -48,7 +43,7 @@ int TestDataEntry(int , char *[]) //------------------------------------------------------------------ dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + entry = gdcm::DataEntry::New(dict); dict->SetVR("US"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -64,7 +59,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 1" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } @@ -79,7 +74,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 2" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } @@ -94,17 +89,17 @@ 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); + entry = gdcm::DataEntry::New(dict); dict->SetVR("LT"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -119,7 +114,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 ) @@ -129,7 +124,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 ) @@ -137,7 +132,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 ) @@ -147,7 +142,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++) @@ -159,18 +154,18 @@ 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); + entry = gdcm::DataEntry::New(dict); dict->SetVR("US"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -186,7 +181,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 ) @@ -196,7 +191,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 ) @@ -206,7 +201,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++) @@ -218,7 +213,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << svalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -236,7 +231,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 ) @@ -246,7 +241,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++) @@ -258,18 +253,18 @@ 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); + entry = gdcm::DataEntry::New(dict); dict->SetVR("UL"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -285,7 +280,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 ) @@ -295,7 +290,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 ) @@ -305,7 +300,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++) @@ -317,7 +312,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << lvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -335,7 +330,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 ) @@ -345,7 +340,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++) @@ -357,18 +352,18 @@ 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); + entry = gdcm::DataEntry::New(dict); dict->SetVR("FL"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -384,7 +379,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 ) @@ -394,7 +389,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 ) @@ -404,7 +399,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++) @@ -416,7 +411,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << fvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -434,7 +429,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 ) @@ -444,7 +439,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++) @@ -456,18 +451,18 @@ 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); + entry = gdcm::DataEntry::New(dict); dict->SetVR("FD"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -483,7 +478,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 ) @@ -493,7 +488,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 ) @@ -503,7 +498,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++) @@ -517,7 +512,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << dvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -535,7 +530,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 ) @@ -545,7 +540,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++) @@ -557,14 +552,14 @@ 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<