예제 #1
0
/**
 * @return true if the Validator behaved as expected when validating
 * TestFile, false otherwise.
 */
bool
TestValidator::test (const TestFile& file)
{
  bool error = false;

  unsigned int id       = file.getConstraintId();

  /* change numbers for specific units tests that report same number */
  if (id == 99502 || id == 99503 || id == 99504)
    id = 10501;

  /* change numbers for specific units tests that report same number */
  if (id == 90502 || id == 90503 || id == 90504)
    id = 90501;

  unsigned int expected = file.getNumFailures();
  unsigned int others   = file.getAdditionalFailId();
  unsigned int num = file.getSequenceId();

  /* for 10311 called using just the id validator you will get 99303
     unless it is from units on a cn element (ie case 31*/
  if (id == 10311 && expected == 1 && num != 31)
  {
    expected = 2;
    others = 99303;
  }

  /* for my new compatibility constraints some will only apply to certain levels
   * so adjust these here
   */
  if (id == 98001)
  {
    if (mValidator.getConsistencyLevel() == 3) expected = 0;
  }

  if (id == 98003)
  {
    if (mValidator.getConsistencyLevel() == 1)
    {
      if (num == 12) 
      {
        others = 91001;
        expected = 2;
      }
    }
  }
  if (id == 98004)
  {
    if (mValidator.getConsistencyLevel() == 1) 
    {
      if (num < 12 && num > 7)
      {
        others = 91001;
        expected = 2;
      }
      else if (num == 6)
      {
        others = 91003;
        expected = 2;
      }
      else if (num == 2)
      {
        others = 91004;
        expected = 2;
      }
      else if (num == 1)
      {
        others = 91002;
        expected = 2;
      }
    }
 /*   if (num == 10 && mValidator.getConsistencyLevel() == 2) 
    {
      others = 92011;
      expected = 2;
    }*/
    if (num == 6 && ((mValidator.getConsistencyLevel() == 2 
                   && mValidator.getConsistencyVersion() == 1)))
    {
      others = 92001;
      expected = 2;
    }
    if (num == 2 && ((mValidator.getConsistencyLevel() == 2 
                   && mValidator.getConsistencyVersion() == 1)))
    {
      others = 92002;
      expected = 2;
    }
  }
  if (id == 98005)
  {
    if (mValidator.getConsistencyLevel() == 1) 
    {
        expected = 1;
        id = 91001;
    }
  }
  if (id == 98006)
  {
    if (num > 1 && ((mValidator.getConsistencyLevel() == 2
      && mValidator.getConsistencyVersion() == 1)
      || (mValidator.getConsistencyLevel() == 1)))
    {
      others = 92002;
      if (mValidator.getConsistencyLevel() == 1)
        others = 91004;
      expected = expected + 1;
    }
  }
  if (id == 98007)
  {
    if (num < 3 && ((mValidator.getConsistencyLevel() == 2 
                   && mValidator.getConsistencyVersion() == 1)
                   || (mValidator.getConsistencyLevel() == 1)))
    {
      others = 92001;
      if (mValidator.getConsistencyLevel() == 1)
        others = 91003;
      expected = 2;
    }
  }
  if (id == 98009)
  {
    if (mValidator.getConsistencyLevel() == 1)
    {
      others = 91004;
      expected = 2;
    }
    else if (mValidator.getConsistencyLevel() == 2 && mValidator.getConsistencyVersion() == 1)
    {
      others = 92002;
      expected = 2;
    }
  }
//  cout << file.getFilename() << endl;
/* NOTE: the error 10218 relating to number of child elements to a 
 * piece/otherwise element is very difficult to synchronise 
 *
 * I went with leaving the result of the read unchanged 
 * but actually logging the errors
 */
  if (id == 99219 && num == 32)
  {
    expected = 2;
  }
  if (id == 10218 && num == 12 && expected == 1)
  {
    expected = 2;
    others = 10213;
  }
  if (id == 10218 && num == 10 && expected == 2)
  {
    expected = 1;
  }
  unsigned int actual   = mValidator.validate( file.getFullname() );

  list<SBMLError>::const_iterator begin = mValidator.getFailures().begin();
  list<SBMLError>::const_iterator end   = mValidator.getFailures().end();



  if (expected != actual)
  {
    error = true;

    cout << endl;
    cout << "Error: " << file.getFilename() << endl;
    cout << "  - Failures:  Expected: "  << expected << "  Actual: " << actual;
    cout << endl << endl;
  }


  unsigned int same = (unsigned int)count_if(begin, end, HasId(id));
  vector<unsigned int> ids;

  if (expected != same && actual != same)
  {
    // need to consider case where the test case has
    // an additional fail
    if (expected - same != 1)
    {
      error = true;
    }
    else
    {
      transform(begin, end, back_inserter(ids), ToId());

      unsigned int match = 0;
      for (unsigned int i = 0; i < ids.size(); i++)
      {
        if (others != 0 && ids.at(i) == others)
        {
          match = 1;
        }
      }

      if (match == 0)
      {
        error = true;
      }
    }
  }

  if (error)
  {      
    cout << endl;
    cout << "Error: " << file.getFilename() << endl;
    cout << "  - Constraints:  Expected: " << id << "  Actual: ";
    cout << endl;
    copy(ids.begin(), ids.end(), ostream_iterator<unsigned int>(cout, " "));
    cout << endl;
  }

  if ( error || isVerbose(id) )
  {
    copy(begin, end, ostream_iterator<SBMLError>(cout, "\n"));
  }

  mValidator.clearFailures();

  return error == false;
}
예제 #2
0
/**
 * @return true if the Validator behaved as expected when validating
 * TestFile, false otherwise.
 */
bool
TestValidator::test (const TestFile& file)
{
    bool error = false;

    unsigned int id       = file.getConstraintId();

    /* change numbers for specific units tests that report same number */
    if (id == 99502 || id == 99503 || id == 99504)
        id = 10501;

    /* change numbers for specific units tests that report same number */
    if (id == 90502 || id == 90503 || id == 90504)
        id = 90501;

    unsigned int expected = file.getNumFailures();
    unsigned int others   = file.getAdditionalFailId();

    unsigned int actual   = mValidator.validate( file.getFullname() );

    list<SBMLError>::const_iterator begin = mValidator.getFailures().begin();
    list<SBMLError>::const_iterator end   = mValidator.getFailures().end();



    if (expected != actual)
    {
        error = true;

        cout << endl;
        cout << "Error: " << file.getFilename() << endl;
        cout << "  - Failures:  Expected: "  << expected << "  Actual: " << actual;
        cout << endl << endl;
    }


    unsigned int same = count_if(begin, end, HasId(id));
    vector<unsigned int> ids;

    if (expected != same && actual != same)
    {
        // need to consider case where the test case has
        // an additional fail
        if (expected - same != 1)
        {
            error = true;
        }
        else
        {
            transform(begin, end, back_inserter(ids), ToId());

            unsigned int match = 0;
            for (unsigned int i = 0; i < ids.size(); i++)
            {
                if (ids.at(i) == others)
                {
                    match = 1;
                }
            }

            if (match == 0)
            {
                error = true;
            }
        }
    }

    if (error)
    {
        cout << endl;
        cout << "Error: " << file.getFilename() << endl;
        cout << "  - Constraints:  Expected: " << id << "  Actual: ";
        cout << endl;
        copy(ids.begin(), ids.end(), ostream_iterator<unsigned int>(cout, " "));
        cout << endl;
    }

    if ( error || isVerbose(id) )
    {
        copy(begin, end, ostream_iterator<SBMLError>(cout, "\n"));
    }

    mValidator.clearFailures();

    return error == false;
}
예제 #3
0
/**
 * @return true if the Validator behaved as expected when validating
 * TestFile, false otherwise.
 */
bool
TestValidator::test (const TestFile& file)
{
  bool error = false;

  unsigned int id       = file.getConstraintId();
  unsigned int expected = file.getNumFailures();
  unsigned int others   = file.getAdditionalFailId();

  unsigned int actual   = mValidator.validate( file.getFullname() );


  list<SBMLError>::const_iterator begin = mValidator.getFailures().begin();
  list<SBMLError>::const_iterator end   = mValidator.getFailures().end();



  if (expected != actual)
  {
    error = true;

    cout << endl;
    cout << "Error: " << file.getFilename() << endl;
    cout << "  - Failures:  Expected: "  << expected << "  Actual: " << actual;
    cout << endl << endl;
  }


  vector<unsigned int> ids;
  transform(begin, end, back_inserter(ids), ToId());

  if (id == 1021204 && ids.at(0) == 99108)
  {
    id = 99108;
  }

  unsigned int same = (unsigned int)count_if(begin, end, HasId(id));

  if (expected != same && actual != same)
  {
    // need to change report if we needed a package to be implemented
    //but this version of libsbml does not have the package
    if (id == 1021204)
    {

    }
    // need to consider case where the test case has
    // an additional fail
    if (expected - same != 1)
    {
      error = true;
    }
    else
    {
      unsigned int match = 0;
      for (unsigned int i = 0; i < ids.size(); i++)
      {
        if (others != 0 && ids.at(i) == others)
        {
          match = 1;
        }
      }

      if (match == 0)
      {
        error = true;
      }
    }
  }

  if (error)
  {      
    cout << endl;
    cout << "Error: " << file.getFilename() << endl;
    cout << "  - Constraints:  Expected: " << id << "  Actual: ";
    cout << endl;
    copy(ids.begin(), ids.end(), ostream_iterator<unsigned int>(cout, " "));
    cout << endl;
  }

  if ( error || isVerbose(id) )
  {
    copy(begin, end, ostream_iterator<SBMLError>(cout, "\n"));
  }

  mValidator.clearFailures();

  return error == false;
}