Changeset 516 for trunk/test


Ignore:
Timestamp:
Dec 9, 2007, 8:58:54 AM (14 years ago)
Author:
Peter Johansson
Message:

adding filename translations in Configuration class. Before checking what type parsing to use, filename is translated according to rules set in config file. Default rule (as before) is to remove trailing .in from filenames. To solve the parsing I added a simple regexp function - see utility.h

Location:
trunk/test
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/repo/db/current

    r513 r516  
    1 55 1l 1
     156 1l 1
  • trunk/test/utility_test.cc

    r507 r516  
    2424#include "utility.h"
    2525
     26#include <algorithm>
     27#include <iterator>
    2628#include <iostream>
    2729#include <string>
     
    2931bool test_hex(int, u_int, std::string);
    3032bool test_equal(bool, std::string, std::string);
     33bool test_regexp(bool, std::string, std::string,
     34                 const std::vector<std::string>&);
    3135
    3236int main(const int argc,const char* argv[])
     
    4347  ok &= test_equal(true,"peter", "p*");
    4448  ok &= test_equal(false,"peter", "p*j");
     49
     50  std::vector<std::string> vec;
     51  ok &= test_regexp(true,"abcde", "abcde", vec);
     52  vec.push_back("");
     53  ok &= test_regexp(true,"abcde", "abcd?e", vec);
     54  vec[0]="c";
     55  ok &= test_regexp(true,"abcde", "ab?de", vec);
     56  vec[0] = "bcd";
     57  ok &= test_regexp(true,"abcde", "a*e", vec);
     58  vec.push_back("");
     59  ok &= test_regexp(true,"abcddf", "a*d*f", vec);
     60  vec[0] = "bc";
     61  vec[1] = "ef";
     62  ok &= test_regexp(true,"abcdefg", "a*d*g", vec);
     63  vec.push_back("");
     64  ok &= test_regexp(true,"abcdefg", "a*d*?g", vec);
    4565
    4666  if (ok)
     
    6989}
    7090
     91bool test_regexp(bool ans, std::string a, std::string b,
     92                 const std::vector<std::string>& vec)
     93{
     94  using namespace theplu::svndigest;
     95  std::vector<std::string> v;
     96  bool res = regexp(a.begin(), a.end(), b.begin(), b.end(), v);
     97  if (res!=ans || v!=vec) {
     98    std::cerr << "regexp(" << a << ", " << b << ") results "
     99              << res << ". Expected " << ans << "\n"
     100              << "resulting vector:\n";
     101    std::copy(v.begin(), v.end(),
     102              std::ostream_iterator<std::string>(std::cerr, "\n"));
     103    std::cerr << "expected:\n";
     104    std::copy(vec.begin(), vec.end(),
     105              std::ostream_iterator<std::string>(std::cerr, "\n"));
     106    return false;
     107  }
     108  return true;
     109
     110}
Note: See TracChangeset for help on using the changeset viewer.