OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [path/] [match_test.go] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package path
6
 
7
import "testing"
8
 
9
type MatchTest struct {
10
        pattern, s string
11
        match      bool
12
        err        error
13
}
14
 
15
var matchTests = []MatchTest{
16
        {"abc", "abc", true, nil},
17
        {"*", "abc", true, nil},
18
        {"*c", "abc", true, nil},
19
        {"a*", "a", true, nil},
20
        {"a*", "abc", true, nil},
21
        {"a*", "ab/c", false, nil},
22
        {"a*/b", "abc/b", true, nil},
23
        {"a*/b", "a/c/b", false, nil},
24
        {"a*b*c*d*e*/f", "axbxcxdxe/f", true, nil},
25
        {"a*b*c*d*e*/f", "axbxcxdxexxx/f", true, nil},
26
        {"a*b*c*d*e*/f", "axbxcxdxe/xxx/f", false, nil},
27
        {"a*b*c*d*e*/f", "axbxcxdxexxx/fff", false, nil},
28
        {"a*b?c*x", "abxbbxdbxebxczzx", true, nil},
29
        {"a*b?c*x", "abxbbxdbxebxczzy", false, nil},
30
        {"ab[c]", "abc", true, nil},
31
        {"ab[b-d]", "abc", true, nil},
32
        {"ab[e-g]", "abc", false, nil},
33
        {"ab[^c]", "abc", false, nil},
34
        {"ab[^b-d]", "abc", false, nil},
35
        {"ab[^e-g]", "abc", true, nil},
36
        {"a\\*b", "a*b", true, nil},
37
        {"a\\*b", "ab", false, nil},
38
        {"a?b", "a☺b", true, nil},
39
        {"a[^a]b", "a☺b", true, nil},
40
        {"a???b", "a☺b", false, nil},
41
        {"a[^a][^a][^a]b", "a☺b", false, nil},
42
        {"[a-ζ]*", "α", true, nil},
43
        {"*[a-ζ]", "A", false, nil},
44
        {"a?b", "a/b", false, nil},
45
        {"a*b", "a/b", false, nil},
46
        {"[\\]a]", "]", true, nil},
47
        {"[\\-]", "-", true, nil},
48
        {"[x\\-]", "x", true, nil},
49
        {"[x\\-]", "-", true, nil},
50
        {"[x\\-]", "z", false, nil},
51
        {"[\\-x]", "x", true, nil},
52
        {"[\\-x]", "-", true, nil},
53
        {"[\\-x]", "a", false, nil},
54
        {"[]a]", "]", false, ErrBadPattern},
55
        {"[-]", "-", false, ErrBadPattern},
56
        {"[x-]", "x", false, ErrBadPattern},
57
        {"[x-]", "-", false, ErrBadPattern},
58
        {"[x-]", "z", false, ErrBadPattern},
59
        {"[-x]", "x", false, ErrBadPattern},
60
        {"[-x]", "-", false, ErrBadPattern},
61
        {"[-x]", "a", false, ErrBadPattern},
62
        {"\\", "a", false, ErrBadPattern},
63
        {"[a-b-c]", "a", false, ErrBadPattern},
64
        {"*x", "xxx", true, nil},
65
}
66
 
67
func TestMatch(t *testing.T) {
68
        for _, tt := range matchTests {
69
                ok, err := Match(tt.pattern, tt.s)
70
                if ok != tt.match || err != tt.err {
71
                        t.Errorf("Match(%#q, %#q) = %v, %v want %v, nil", tt.pattern, tt.s, ok, err, tt.match)
72
                }
73
        }
74
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.