diff --git a/Source/Tests/Tests.dsp b/Source/Tests/Tests.dsp index ebeca2b4..4a82832c 100644 --- a/Source/Tests/Tests.dsp +++ b/Source/Tests/Tests.dsp @@ -92,6 +92,10 @@ LINK32=link.exe # PROP Default_Filter "" # Begin Source File +SOURCE=..\dirreader.cpp +# End Source File +# Begin Source File + SOURCE=..\growbuf.cpp # End Source File # Begin Source File @@ -120,6 +124,10 @@ SOURCE=.\mmap.cpp # End Source File # Begin Source File +SOURCE=.\specmatch.cpp +# End Source File +# Begin Source File + SOURCE=.\textrunner.cpp # End Source File # End Group @@ -128,6 +136,10 @@ SOURCE=.\textrunner.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=..\dirreader.h +# End Source File +# Begin Source File + SOURCE=..\mmap.h # End Source File # End Group diff --git a/Source/Tests/specmatch.cpp b/Source/Tests/specmatch.cpp new file mode 100644 index 00000000..56a79c7e --- /dev/null +++ b/Source/Tests/specmatch.cpp @@ -0,0 +1,45 @@ +#include +#include "../dirreader.h" + +#include + +using namespace std; + +class SpecTest : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE( SpecTest ); + CPPUNIT_TEST( testMatches ); + CPPUNIT_TEST_SUITE_END(); + +public: + void testMatches() { + testMatch("test.exe", "test.exe", true); + testMatch("test", "test", true); + testMatch("test.exe", "test.*", true); + testMatch("test", "test.*", true); + testMatch("test", "????", true); + testMatch("test", "???", false); + testMatch("test", "*.exe", false); + testMatch("test.exe.bat", "*.exe", false); + testMatch("test.exe.bat", "*.bat", true); + testMatch("test.exe.bat", "*t", true); + testMatch("test.exe.bat", "*", true); + testMatch("test.exe.bat", "*x*", true); + testMatch("test.exe.exe", "*.*", true); + testMatch("test.exe.bat", "*.b*", true); + testMatch("test.exe.bat", "tes?.*.bat", true); + testMatch("test.exe.bat", "tes?.*bat", true); + testMatch("test.exe.bat", "tes?.*bat***.", true); + testMatch("test.exe", "????.*", true); + testMatch("testing.exe", "????.*", false); + } + +private: + + void testMatch(string name, string spec, bool result) { + CPPUNIT_ASSERT_EQUAL( dir_reader::matches(name, spec), result ); + } + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( SpecTest );