Program: 72580
Project: 72580
Buggy source:
/** 
 * Check the csv file against equations. The equations come from sparse_fmi by James Nutaro. Some variance is acceptable, though the test fails if there is too much.
 * @param testName The name of the test, ex. "Linsys".
 * @param csvFile The comma separated file to be checked, typically generatedby the  {@link #modelExchange(String)} method.
 * @param checkX2 True if the 3rd argument is x2 and should be checked.
 * @exception Exception If there is a problem parsing the file.
 */
public void modelExchangeCheck(String testName,String csvFile,boolean checkX2) throws Exception {
  double x1MaximumError=0.0;
  double x2MaximumError=0.0;
  double epsilon=0.003;
  int row=0;
  String line=null;
  BufferedReader bufferedReader=null;
  try {
    bufferedReader=new BufferedReader(new FileReader(csvFile));
    while ((line=bufferedReader.readLine()) != null) {
      String[] fields=line.split("String_Node_Str");
      row++;
      if (row > 1) {
        double t=Double.valueOf(fields[0]);
        double x1=Double.valueOf(fields[1]);
        double x1CalculatedValue=0.0;
        double x2=0.0;
        double x2CalculatedValue=0.0;
        String message="String_Node_Str" + testName + "String_Node_Str"+ csvFile+ "String_Node_Str"+ row+ "String_Node_Str"+ t+ "String_Node_Str"+ x1+ "String_Node_Str"+ x1CalculatedValue+ (checkX2 ? ("String_Node_Str" + x2 + "String_Node_Str"+ x2CalculatedValue) : "String_Node_Str");
        if (checkX2) {
          x1CalculatedValue=1.0 * Math.exp(-0.5 * t);
          x2=Double.valueOf(fields[2]);
          x2CalculatedValue=2.0 * Math.exp(-1.0 * t);
          x2MaximumError=Math.max(x2MaximumError,Math.abs(x2 - x2CalculatedValue));
          assertEquals(message,x2,x2CalculatedValue,epsilon);
        }
 else {
          x1CalculatedValue=1.0 * Math.exp(-1.0 * t);
        }
        x1MaximumError=Math.max(x1MaximumError,Math.abs(x1 - x1CalculatedValue));
        assertEquals(message,x1,x1CalculatedValue,epsilon);
      }
    }
  }
  finally {
    if (bufferedReader != null) {
      bufferedReader.close();
    }
  }
  System.out.println(testName + "String_Node_Str" + x1MaximumError+ (checkX2 ? ("String_Node_Str" + x2MaximumError) : "String_Node_Str")+ "String_Node_Str");
  assertTrue("String_Node_Str" + x1MaximumError + "String_Node_Str"+ epsilon,x1MaximumError < epsilon);
  assertTrue("String_Node_Str" + x2MaximumError + "String_Node_Str"+ epsilon,x2MaximumError < epsilon);
}

Fixed version (ground truth):
/** 
 * Check the csv file against equations. The equations come from sparse_fmi by James Nutaro. Some variance is acceptable, though the test fails if there is too much.
 * @param testName The name of the test, ex. "Linsys".
 * @param csvFile The comma separated file to be checked, typically generatedby the  {@link #modelExchange(String)} method.
 * @param checkX2 True if the 3rd argument is x2 and should be checked.
 * @exception Exception If there is a problem parsing the file.
 */
public void modelExchangeCheck(String testName,String csvFile,boolean checkX2) throws Exception {
  double x1MaximumError=0.0;
  double x2MaximumError=0.0;
  double epsilon=0.003;
  int row=0;
  String line=null;
  BufferedReader bufferedReader=null;
  try {
    bufferedReader=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(csvFile),java.nio.charset.Charset.defaultCharset()));
    while ((line=bufferedReader.readLine()) != null) {
      String[] fields=line.split("String_Node_Str");
      row++;
      if (row > 1) {
        double t=Double.valueOf(fields[0]);
        double x1=Double.valueOf(fields[1]);
        double x1CalculatedValue=0.0;
        double x2=0.0;
        double x2CalculatedValue=0.0;
        String message="String_Node_Str" + testName + "String_Node_Str"+ csvFile+ "String_Node_Str"+ row+ "String_Node_Str"+ t+ "String_Node_Str"+ x1+ "String_Node_Str"+ x1CalculatedValue+ (checkX2 ? ("String_Node_Str" + x2 + "String_Node_Str"+ x2CalculatedValue) : "String_Node_Str");
        if (checkX2) {
          x1CalculatedValue=1.0 * Math.exp(-0.5 * t);
          x2=Double.valueOf(fields[2]);
          x2CalculatedValue=2.0 * Math.exp(-1.0 * t);
          x2MaximumError=Math.max(x2MaximumError,Math.abs(x2 - x2CalculatedValue));
          assertEquals(message,x2,x2CalculatedValue,epsilon);
        }
 else {
          x1CalculatedValue=1.0 * Math.exp(-1.0 * t);
        }
        x1MaximumError=Math.max(x1MaximumError,Math.abs(x1 - x1CalculatedValue));
        assertEquals(message,x1,x1CalculatedValue,epsilon);
      }
    }
  }
  finally {
    if (bufferedReader != null) {
      bufferedReader.close();
    }
  }
  System.out.println(testName + "String_Node_Str" + x1MaximumError+ (checkX2 ? ("String_Node_Str" + x2MaximumError) : "String_Node_Str")+ "String_Node_Str");
  assertTrue("String_Node_Str" + x1MaximumError + "String_Node_Str"+ epsilon,x1MaximumError < epsilon);
  assertTrue("String_Node_Str" + x2MaximumError + "String_Node_Str"+ epsilon,x2MaximumError < epsilon);
}