Changeset 1052 for trunk/test


Ignore:
Timestamp:
Apr 18, 2010, 4:39:57 AM (11 years ago)
Author:
Peter Johansson
Message:

refs #450. using fnmatch in codon fil name pattern match.

Location:
trunk/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/config_test.cc

    r996 r1052  
    5959      suite.add(false);
    6060    }
    61     if (!c.codon("../dir/test.cc")){
     61    if (!c.codon("/dir/test.cc")){
    6262      suite.out() << "No codon for test.cc\n";
    6363      suite.add(false);
  • trunk/test/utility_test.cc

    r978 r1052  
    2929
    3030bool test_hex(int, unsigned int, std::string);
    31 bool test_equal(bool, std::string, std::string);
     31bool test_fnmatch(bool, std::string, std::string);
    3232bool test_regexp(bool, std::string, std::string,
    3333                 const std::vector<std::string>&);
     
    4141  ok &= test_hex(16,2, "10");
    4242
    43   ok &= test_equal(true,"peter", "peter");
    44   ok &= test_equal(false,"peter", "peterj");
    45   ok &= test_equal(true,"p*", "peterj");
    46   ok &= test_equal(true,"peter", "p*");
    47   ok &= test_equal(false,"peter", "p*j");
    48   ok &= test_equal(true,"peter", "*peter");
     43  ok &= test_fnmatch(true,"peter", "peter");
     44  ok &= test_fnmatch(false,"peter", "peterj");
     45  ok &= test_fnmatch(true,"p*", "peterj");
     46  ok &= test_fnmatch(true, "p*", "peter");
     47  ok &= test_fnmatch(false, "p*j", "peter");
     48  ok &= test_fnmatch(true, "*peter", "peter");
     49
     50  ok &= test_fnmatch(true, "filename", "filename");
     51  ok &= test_fnmatch(true, "*name", "filename");
     52  ok &= test_fnmatch(true, "[fa]il?name", "filename");
     53  ok &= test_fnmatch(true, "*name", "/path/to/filename");
     54  ok &= test_fnmatch(true, "*name", "file.name");
     55  // posix dictates that leading persion can not be matched by wildcard
     56  ok &= test_fnmatch(false, "*.txt", ".file.txt");
    4957
    5058  std::vector<std::string> vec;
     
    6977}
    7078
    71 bool test_equal(bool answ, std::string a, std::string b)
     79bool test_fnmatch(bool answ, std::string a, std::string b)
    7280{
    73   if (theplu::svndigest::equal(a.begin(), a.end(), b.begin(), b.end())==answ)
     81  using namespace theplu::svndigest;
     82  bool res = fnmatch(a.c_str(), b.c_str());
     83  if (res == answ)
    7484    return true;
    75   std::cerr << "equal(" << a << ", " << b << ") results "
    76             << theplu::svndigest::equal(a.begin(), a.end(),b.begin(), b.end())
     85  std::cerr << "fnmatch(" << a << ", " << b << ") results "
     86            << res
    7787            << ". Expects " << answ << std::endl;
    7888  return false;
     
    107117  }
    108118  return true;
    109 
    110119}
Note: See TracChangeset for help on using the changeset viewer.