- //////////////// Step 4:
-
- if (dataSize != dataSizeWritten)
- {
- std::cout << std::endl
- << " Pixel areas lengths differ: "
- << dataSize << " # " << dataSizeWritten << std::endl;
- delete (char*)imageData;
- delete (char*)imageDataWritten;
- delete header;
- delete file;
- delete reread;
- return 1;
- }
-
- if (int res=memcmp(imageData, imageDataWritten, dataSize) !=0)
- {
- std::cout << std::endl
- << " Pixel differ (as expanded in memory)." << std::endl;
- delete (char*)imageData;
- delete (char*)imageDataWritten;
- delete header;
- delete file;
- delete reread;
- return 1;
- }
- std::cout << " 4...OK." << std::endl ;
-
- //////////////// Clean up:
- delete (char*)imageData;
- delete (char*)imageDataWritten;
- delete header;
- delete file;
- delete reread;
- }
-
- return 0;
+ // Test the data size
+ if (dataSize != dataSizeWritten)
+ {
+ std::cout << "Failed" << std::endl
+ << " Pixel areas lengths differ: "
+ << dataSize << " # " << dataSizeWritten << std::endl;
+ delete file;
+ delete filehelper;
+ delete fileout;
+ delete reread;
+ return 1;
+ }
+
+ // Test the data's content
+ if (memcmp(imageData, imageDataWritten, dataSize) !=0)
+ {
+ std::cout << "Failed" << std::endl
+ << " Pixel differ (as expanded in memory)." << std::endl;
+ delete file;
+ delete filehelper;
+ delete fileout;
+ delete reread;
+ return 1;
+ }
+ std::cout << "4...OK." << std::endl ;
+
+ //////////////// Clean up:
+ delete file;
+ delete filehelper;
+ delete fileout;
+ delete reread;
+
+ return 0;
+}
+
+int TestReadWriteReadCompare(int argc, char *argv[])
+{
+ int result = 0;
+
+ if (argc == 4)
+ gdcm::Debug::DebugOn();
+
+ if (argc >= 3)
+ {
+ const std::string input = argv[1];
+ const std::string output = argv[2];
+ result += CompareInternal(input, output);
+ }
+ else if( argc > 4 || argc == 2 )
+ {
+ std::cout << "Please read the manual" << std::endl;
+ }
+ else
+ {
+ std::cout<< "Test::TestReadWriteReadCompare: description " << std::endl;
+ std::cout << " For all images in gdcmData (and not blacklisted in "
+ "Test/CMakeLists.txt)" << std::endl;
+ std::cout << " apply the following multistep test: " << std::endl;
+ std::cout << " step 1: parse the image (as gdcmFile) and call"
+ << " IsReadable(). " << std::endl;
+ std::cout << " step 2: write the corresponding image in DICOM V3 "
+ << "with explicit" << std::endl
+ << " Value Representation in temporary file "
+ << "TestReadWriteReadCompare.dcm." << std::endl;
+ std::cout << " step 3: read the image written on step2 and call "
+ << " IsReadable(). " << std::endl;
+ std::cout << " step 4: compare (in memory with memcmp) that the two "
+ << "images " << std::endl
+ << " match (as expanded by gdcm)." << std::endl;
+
+ int i = 0;
+ while( gdcmDataImages[i] != 0 )
+ {
+ std::string filename = GDCM_DATA_ROOT;
+ filename += "/";
+ filename += gdcmDataImages[i++];
+ result += CompareInternal(filename, "TestReadWriteReadCompare.dcm");
+ }
+ }
+ return result;