2004-12-10 10:35:40 +00:00
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
#include "../dirreader.h"
|
|
|
|
|
2010-03-24 17:22:56 +00:00
|
|
|
#include "tstring.h"
|
2004-12-10 10:35:40 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class SpecTest : public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE( SpecTest );
|
|
|
|
CPPUNIT_TEST( testMatches );
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void testMatches() {
|
2010-03-24 17:22:56 +00:00
|
|
|
testMatch(TEXT("test.exe"), TEXT("test.exe"), true);
|
|
|
|
testMatch(TEXT("test"), TEXT("test"), true);
|
|
|
|
testMatch(TEXT("test.exe"), TEXT("test.*"), true);
|
|
|
|
testMatch(TEXT("test"), TEXT("test.*"), true);
|
|
|
|
testMatch(TEXT("test"), TEXT("????"), true);
|
|
|
|
testMatch(TEXT("test"), TEXT("???"), false);
|
|
|
|
testMatch(TEXT("test"), TEXT("*.exe"), false);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("*.exe"), false);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("*.bat"), true);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("*t"), true);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("*"), true);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("*x*"), true);
|
|
|
|
testMatch(TEXT("test.exe.exe"), TEXT("*.*"), true);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("*.b*"), true);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("tes?.*.bat"), true);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("tes?.*bat"), true);
|
|
|
|
testMatch(TEXT("test.exe.bat"), TEXT("tes?.*bat***."), true);
|
|
|
|
testMatch(TEXT("test.exe"), TEXT("????.*"), true);
|
|
|
|
testMatch(TEXT("testing.exe"), TEXT("????.*"), false);
|
2004-12-10 10:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2010-03-24 17:22:56 +00:00
|
|
|
void testMatch(tstring name, tstring spec, bool result) {
|
2004-12-10 10:35:40 +00:00
|
|
|
CPPUNIT_ASSERT_EQUAL( dir_reader::matches(name, spec), result );
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( SpecTest );
|