]> Creatis software - gdcm.git/blobdiff - Testing/TestAllEntryVerify.cxx
ENH: Apply first patch toward better string comparison when dealing with broken DICOM...
[gdcm.git] / Testing / TestAllEntryVerify.cxx
index 6daec820304308f7a2599d8a1d6df168ebcd91ce..a2dc4abc00c9b72a1150623a3b8805a3d5effd5a 100644 (file)
@@ -9,7 +9,7 @@
 #include "gdcmDataImages.h"
 
 typedef std::string EntryValueType;   // same type as ValEntry::value
-typedef std::map< TagKey, EntryValueType > MapEntryValues;
+typedef std::map< gdcm::TagKey, EntryValueType > MapEntryValues;
 typedef MapEntryValues* MapEntryValuesPtr;
 typedef std::string FileNameType;
 typedef std::map< FileNameType, MapEntryValuesPtr > MapFileValuesType;
@@ -194,11 +194,19 @@ bool ReferenceFileParser::Check()
          std::string testedValue = tested->GetEntryByNumber(group, element);
          if ( testedValue != j->second )
          {
-            std::cout << Indent << "Uncorrect value for key " << key << std::endl
-                 << Indent << "   read value [" << testedValue << "]" << std::endl
-                 << Indent << "   reference value [" << j->second << "]"
-                           << std::endl;
+            // Oops make sure this is only the \0 that differ
+            if( testedValue[j->second.size()] != '\0' ||
+                strncmp(testedValue.c_str(), 
+                        j->second.c_str(), j->second.size()) != 0)
+            {
+               std::cout << Indent << "Uncorrect value for key " 
+                         << key << std::endl
+                         << Indent << "   read value      [" 
+                         << testedValue << "]" << std::endl
+                         << Indent << "   reference value [" 
+                         << j->second << "]" << std::endl;
             return false;
+            }
          }
       }
       delete tested;
@@ -306,7 +314,7 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException )
 
    while ( ! from.eof() )
    {
-      getline( from, line );
+      std::getline( from, line );
 
       /// This is how we usually end the parsing because we hit EOF:
       if ( ! from.good() )
@@ -533,7 +541,7 @@ void ReferenceFileParser::ParseRegularLine( std::string& line)
 bool ReferenceFileParser::SecondPassReferenceFile()
    throw ( ParserException )
 {
-   TagKey key;
+   gdcm::TagKey key;
    EntryValueType value;
    std::string line;
    bool inBlock = false;
@@ -541,7 +549,7 @@ bool ReferenceFileParser::SecondPassReferenceFile()
 
    while ( !from.eof() )
    {
-      getline( from, line );
+      std::getline( from, line );
       lineNumber++;
 
       CleanUpLine( line );