| 1 |
#include <cppunit/extensions/HelperMacros.h> |
| 2 |
#include "../dirreader.h" |
| 3 |
#include "../tstring.h" |
| 4 |
|
| 5 |
#ifndef TEXT |
| 6 |
#define TEXT _T |
| 7 |
#endif |
| 8 |
|
| 9 |
using namespace std; |
| 10 |
|
| 11 |
class SpecTest : public CppUnit::TestFixture { |
| 12 |
|
| 13 |
CPPUNIT_TEST_SUITE( SpecTest ); |
| 14 |
CPPUNIT_TEST( testMatches ); |
| 15 |
CPPUNIT_TEST_SUITE_END(); |
| 16 |
|
| 17 |
public: |
| 18 |
void testMatches() { |
| 19 |
testMatch(TEXT("test.exe"), TEXT("test.exe"), true); |
| 20 |
testMatch(TEXT("test"), TEXT("test"), true); |
| 21 |
testMatch(TEXT("test.exe"), TEXT("test.*"), true); |
| 22 |
testMatch(TEXT("test"), TEXT("test.*"), true); |
| 23 |
testMatch(TEXT("test"), TEXT("????"), true); |
| 24 |
testMatch(TEXT("test"), TEXT("???"), false); |
| 25 |
testMatch(TEXT("test"), TEXT("*.exe"), false); |
| 26 |
testMatch(TEXT("test.exe.bat"), TEXT("*.exe"), false); |
| 27 |
testMatch(TEXT("test.exe.bat"), TEXT("*.bat"), true); |
| 28 |
testMatch(TEXT("test.exe.bat"), TEXT("*t"), true); |
| 29 |
testMatch(TEXT("test.exe.bat"), TEXT("*"), true); |
| 30 |
testMatch(TEXT("test.exe.bat"), TEXT("*x*"), true); |
| 31 |
testMatch(TEXT("test.exe.exe"), TEXT("*.*"), true); |
| 32 |
testMatch(TEXT("test.exe.bat"), TEXT("*.b*"), true); |
| 33 |
testMatch(TEXT("test.exe.bat"), TEXT("tes?.*.bat"), true); |
| 34 |
testMatch(TEXT("test.exe.bat"), TEXT("tes?.*bat"), true); |
| 35 |
testMatch(TEXT("test.exe.bat"), TEXT("tes?.*bat***."), true); |
| 36 |
testMatch(TEXT("test.exe"), TEXT("????.*"), true); |
| 37 |
testMatch(TEXT("testing.exe"), TEXT("????.*"), false); |
| 38 |
} |
| 39 |
|
| 40 |
private: |
| 41 |
|
| 42 |
void testMatch(tstring name, tstring spec, bool result) { |
| 43 |
CPPUNIT_ASSERT_EQUAL( dir_reader::matches(name, spec), result ); |
| 44 |
} |
| 45 |
|
| 46 |
}; |
| 47 |
|
| 48 |
CPPUNIT_TEST_SUITE_REGISTRATION( SpecTest ); |