NSIS/Source/Tests/specmatch.cpp
wizou 752d7d239a Jim Park's Unicode NSIS merging - Step 1 : switch to TCHARs where relevant.
Compiler output is identical before & after this step

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/branches/wizou@6036 212acab6-be3b-0410-9dea-997c60f758d6
2010-03-24 17:22:56 +00:00

45 lines
1.5 KiB
C++

#include <cppunit/extensions/HelperMacros.h>
#include "../dirreader.h"
#include "tstring.h"
using namespace std;
class SpecTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( SpecTest );
CPPUNIT_TEST( testMatches );
CPPUNIT_TEST_SUITE_END();
public:
void testMatches() {
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);
}
private:
void testMatch(tstring name, tstring spec, bool result) {
CPPUNIT_ASSERT_EQUAL( dir_reader::matches(name, spec), result );
}
};
CPPUNIT_TEST_SUITE_REGISTRATION( SpecTest );