pauldick    01/09/19 10:17:44

  Modified:    c/Tests/Harness FileUtility.cpp
  Log:
  Output number of missing gold files. Domcompare was not
  detecting additional child nodes in result.  Updated text comparison
  routine to detect missing gold files.
  
  Revision  Changes    Path
  1.14      +54 -14    xml-xalan/c/Tests/Harness/FileUtility.cpp
  
  Index: FileUtility.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/Tests/Harness/FileUtility.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FileUtility.cpp   2001/09/14 20:48:33     1.13
  +++ FileUtility.cpp   2001/09/19 17:17:44     1.14
  @@ -325,7 +325,7 @@
                           XalanSourceTreeDocument* dom,
                           const XSLTInputSource& goldInputSource)
   {
  -     const XalanDOMString mimeEncoding("whatever");
  +     const XalanDOMString mimeEncoding("");
        XalanFileOutputStream myOutput(theOutputFile);
        XalanOutputStreamPrintWriter myResultWriter(myOutput);
        FormatterListener* theFormatter = getXMLFormatter(true,true,true,
  @@ -410,19 +410,37 @@
        FILE *result, *gold;                    // declare files
        char rline[132], gline[132];    // declare buffers to hold single line from 
file
        char temp[10];                                  // buffer to hold line number
  +     char lineNum = 1;
   
  -     //cout << "\nGold: " << goldFile << "\nResult: " << outputFile << endl << endl;
  +     // Set fail data incase there are i/o problems with the files to compare.
  +     data.expected = XalanDOMString(" ");
  +     data.actual = XalanDOMString(" ");
  +     data.currentNode = XalanDOMString("Line: 0");
  +
        result = fopen(outputFile, "r");
        gold   = fopen(goldFile, "r");
   
  -     char lineNum = 1;       
  -     fgets(gline, sizeof(gline), gold );             // read in a line from each 
file
  -     fgets(rline, sizeof(rline), result );
  +     if (!gold || !result)
  +     {
  +             data.msg = "Failed to open either Gold or Result file";
  +             data.nogold += 1;
  +             return false;
  +     }
   
        while( !feof(result) && !feof(gold))
        {
  -             int i = 0;
  +             fgets(gline, sizeof(gline), gold );
  +             fgets(rline, sizeof(rline), result );
  +             sprintf(temp,"%d",lineNum);
  +
  +             if (ferror(gold) || ferror(result))
  +             {
  +                     data.msg = "Read Error on either Gold or Result file";
  +                     data.currentNode = XalanDOMString("Line: ") + 
XalanDOMString(temp);
  +                     return false;
  +             }
   
  +             int i = 0;
                while(gline[i] != '\n') 
                {
                        if (gline[i] == rline[i]) 
  @@ -432,7 +450,6 @@
                        }
                        else 
                        {
  -                             sprintf(temp,"%d",lineNum);
                                data.msg = "Error: Text based comparison failure";
                                data.expected = XalanDOMString("<![CDATA[") + 
XalanDOMString(gline) + XalanDOMString("]]>");
                                data.actual = XalanDOMString("<![CDATA[") + 
XalanDOMString(rline) + XalanDOMString("]]>");
  @@ -440,16 +457,13 @@
                                data.fail += 1;
                                return false;
                        }
  -
                }
   
                lineNum += 1;
  -             fgets(gline, sizeof(gline), gold );
  -             fgets(rline, sizeof(rline), result );
        }
   
        return true;
  -     }
  +}
   
   
   
  @@ -704,6 +718,30 @@
                        return false;
                }
        }
  +     else if (domNextNode)
  +     {
  +             // The result doc has additional Children. If the additional node is a 
text node
  +             // then gather up the text and print it out.
  +             if ( domNextNode->getNodeType() == XalanNode::TEXT_NODE)
  +             {
  +                     collectData("Error: Transformed Doc has additional Child 
nodes: ", 
  +                                     docNodeName,
  +                                     XalanDOMString("NOTHING"),               
  +                                     XalanDOMString(domNextNode->getNodeName()) + 
XalanDOMString("  \"") +
  +                                     XalanDOMString(domNextNode->getNodeValue()) + 
XalanDOMString("\""));
  +             }
  +             // Additional node is NOT text, so just print it's Name.
  +             else
  +             {
  +                     collectData("Error: Transformed Doc has additional Child node: 
", 
  +                                             docNodeName,
  +                                             XalanDOMString("NOTHING"),             
  
  +                                             
XalanDOMString(domNextNode->getNodeName()));
  +
  +             }
  +             return false;
  +
  +     }
   
        goldNextNode = gold.getNextSibling();
        domNextNode = doc.getNextSibling();
  @@ -716,7 +754,8 @@
                                return false;
                }
                else
  -             {
  +             {       // domcomtest10 used to fail here,  now it is caught above, 
with the error
  +                     // "Transformed Doc has additional Child nodes:"
                        collectData("Error: Element missing SiblingNode. ", 
                                                 docNodeName,
                                                 
XalanDOMString(goldNextNode->getNodeName()),
  @@ -856,7 +895,8 @@
   
        logfile.logElementWAttrs(10, "RunResults", runResults, "xxx");  
   
  -     cout << "\nPassed " << data.pass << endl;
  -     cout << "\nFailed " << data.fail << endl;
  +     cout << "\nPassed " << data.pass;
  +     cout << "\nFailed " << data.fail;
  +     cout << "\nMissing Gold " << data.nogold << endl;
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to