File: specmatch.cpp

package info (click to toggle)
nsis 3.04-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,076 kB
  • sloc: cpp: 36,735; ansic: 26,691; python: 1,282; asm: 712; xml: 511; pascal: 215; makefile: 205
file content (48 lines) | stat: -rwxr-xr-x 1,587 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <cppunit/extensions/HelperMacros.h>
#include "../dirreader.h"
#include "../tstring.h"

#ifndef TEXT
#define TEXT _T
#endif

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 );