Changeset 718 for trunk


Ignore:
Timestamp:
Nov 30, 2008, 10:03:11 PM (13 years ago)
Author:
Peter Johansson
Message:

refs #338 added some tests for BlameStats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/stats_test.cc

    r717 r718  
    4242namespace svndigest{
    4343
    44   bool check(const Stats& stats, const std::vector<size_t>& correct,
     44  bool check(const Stats& stats, const std::vector<int>& correct,
    4545             int linetype, const std::string& descr, const std::string& author);
    4646  std::string path(void);
     
    9797    ok &= test_base_class(cs);
    9898
    99     std::vector<size_t> correct(62,0);
     99    std::vector<int> correct(62,0);
    100100    correct[15] = 71;
    101101    correct[16] = 3;
     
    144144    ok &= test_base_class(cs);
    145145
     146    std::vector<int> correct(62,0);
     147    correct[15] = 71;
     148    correct[16] = -1;
     149    correct[17] = 2;
     150    correct[28] = 31;
     151    correct[30] = 25;
     152    correct[42] = -1;
     153    ok &= check(cs, correct, LineTypeParser::total, "total", "jari");
     154    correct[42] = 0;
     155    correct[43] = 1;
     156    ok &= check(cs, correct, LineTypeParser::total, "total", "all");
     157    std::fill(correct.begin(), correct.end(), 0);
     158    correct[42] = 1;
     159    correct[43] = 1;
     160    ok &= check(cs, correct, LineTypeParser::copyright, "copyright", "peter");
     161    std::fill(correct.begin(), correct.end(), 0);
     162    correct[15] = 49;
     163    correct[17] = 2;
     164    correct[28] = 8;
     165    correct[30] = 54-29;
     166    ok &= check(cs, correct, LineTypeParser::code, "code", "jari");
     167    std::fill(correct.begin(), correct.end(), 0);
     168    correct[15] = 5;
     169    correct[16] = -1;
     170    correct[28] = 13;
     171    correct[30] = 7-3;
     172    ok &= check(cs, correct, LineTypeParser::comment, "comment", "jari");
     173    std::fill(correct.begin(), correct.end(), 0);
     174    correct[15] = 17;
     175    correct[28] = 10-1;
     176    correct[30] = 2-6;
     177    ok &= check(cs, correct, LineTypeParser::other, "other", "jari");
     178
    146179    return ok;
    147180  }
     
    179212
    180213    // testing copyright lines for peter
    181     std::vector<size_t> correct(48,0);
     214    std::vector<int> correct(48,0);
    182215    correct[47]=2;
    183216    ok &= check(cs, correct, LineTypeParser::copyright, "copyright", "peter");
     
    223256  }
    224257 
    225   bool check(const Stats& stats, const std::vector<size_t>& correct,
     258  bool check(const Stats& stats, const std::vector<int>& correct,
    226259             int linetype, const std::string& descr, const std::string& author)
    227260  {
     
    232265      size_t n = stats(linetype, author, rev);
    233266      if (n != sum[rev]){
    234         std::cerr << "error: " << descr << " " << author << " rev:" << rev
     267        std::cout << "error: " << descr << " " << author << " rev:" << rev
    235268                  << ": found " << n << " expected " << sum[rev] << "\n";
    236269        ok = false;
Note: See TracChangeset for help on using the changeset viewer.