Fossil SCM

fossil-scm / test / glob.test
Blame History Raw 191 lines
1
#
2
# Copyright (c) 2013 D. Richard Hipp
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the Simplified BSD License (also
6
# known as the "2-Clause License" or "FreeBSD License".)
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but without any warranty; without even the implied warranty of
10
# merchantability or fitness for a particular purpose.
11
#
12
# Author contact information:
13
# [email protected]
14
# http://www.hwaci.com/drh/
15
#
16
############################################################################
17
#
18
# Test glob pattern parsing
19
#
20
21
test_setup ""
22
23
proc glob-parse {testname args} {
24
set i 1
25
foreach {pattern string result} $args {
26
fossil test-glob $pattern $string
27
test glob-parse-$testname.$i {$::RESULT eq $result}
28
incr i
29
}
30
}
31
32
glob-parse 100 test test [string map [list \r\n \n] \
33
{SQL expression: (x GLOB 'test')
34
pattern[0] = [test]
35
1 1 test}]
36
37
glob-parse 101 "one two" one [string map [list \r\n \n] \
38
{SQL expression: (x GLOB 'one' OR x GLOB 'two')
39
pattern[0] = [one]
40
pattern[1] = [two]
41
1 1 one}]
42
43
glob-parse 102 t* test [string map [list \r\n \n] \
44
{SQL expression: (x GLOB 't*')
45
pattern[0] = [t*]
46
1 1 test}]
47
48
glob-parse 103 "o* two" one [string map [list \r\n \n] \
49
{SQL expression: (x GLOB 'o*' OR x GLOB 'two')
50
pattern[0] = [o*]
51
pattern[1] = [two]
52
1 1 one}]
53
54
glob-parse 104 {"o* two" "three four"} "one two" [string map [list \r\n \n] \
55
{SQL expression: (x GLOB 'o* two' OR x GLOB 'three four')
56
pattern[0] = [o* two]
57
pattern[1] = [three four]
58
1 1 one two}]
59
60
glob-parse 105 {"o* two" "three four"} "two one" [string map [list \r\n \n] \
61
{SQL expression: (x GLOB 'o* two' OR x GLOB 'three four')
62
pattern[0] = [o* two]
63
pattern[1] = [three four]
64
0 0 two one}]
65
66
glob-parse 106 "\"o*\ntwo\" \"three\nfour\"" "one\ntwo" \
67
[string map [list \r\n \n] \
68
{SQL expression: (x GLOB 'o*
69
two' OR x GLOB 'three
70
four')
71
pattern[0] = [o*
72
two]
73
pattern[1] = [three
74
four]
75
1 1 one
76
two}]
77
78
glob-parse 107 "\"o*\ntwo\" \"three\nfour\"" "two\none" \
79
[string map [list \r\n \n] \
80
{SQL expression: (x GLOB 'o*
81
two' OR x GLOB 'three
82
four')
83
pattern[0] = [o*
84
two]
85
pattern[1] = [three
86
four]
87
0 0 two
88
one}]
89
90
glob-parse 108 "\"o*\rtwo\" \"three\rfour\"" "one\rtwo" \
91
[string map [list \r\n \n] \
92
{SQL expression: (x GLOB 'o*
93
two' OR x GLOB 'three
94
four')
95
pattern[0] = [o*
96
two]
97
pattern[1] = [three
98
four]
99
1 1 one
100
two}]
101
102
glob-parse 109 "\"o*\rtwo\" \"three\rfour\"" "two\rone" \
103
[string map [list \r\n \n] \
104
{SQL expression: (x GLOB 'o*
105
two' OR x GLOB 'three
106
four')
107
pattern[0] = [o*
108
two]
109
pattern[1] = [three
110
four]
111
0 0 two
112
one}]
113
114
glob-parse 110 "'o*\ntwo' 'three\nfour'" "one\ntwo" \
115
[string map [list \r\n \n] \
116
{SQL expression: (x GLOB 'o*
117
two' OR x GLOB 'three
118
four')
119
pattern[0] = [o*
120
two]
121
pattern[1] = [three
122
four]
123
1 1 one
124
two}]
125
126
glob-parse 111 "'o*\ntwo' 'three\nfour'" "two\none" \
127
[string map [list \r\n \n] \
128
{SQL expression: (x GLOB 'o*
129
two' OR x GLOB 'three
130
four')
131
pattern[0] = [o*
132
two]
133
pattern[1] = [three
134
four]
135
0 0 two
136
one}]
137
138
glob-parse 112 "\"'o*' 'two'\" \"'three' 'four'\"" "'one' 'two'" \
139
[string map [list \r\n \n] \
140
{SQL expression: (x GLOB '''o*'' ''two''' OR x GLOB '''three'' ''four''')
141
pattern[0] = ['o*' 'two']
142
pattern[1] = ['three' 'four']
143
1 1 'one' 'two'}]
144
145
glob-parse 113 "\"'o*' 'two'\" \"'three' 'four'\"" "two one" \
146
[string map [list \r\n \n] \
147
{SQL expression: (x GLOB '''o*'' ''two''' OR x GLOB '''three'' ''four''')
148
pattern[0] = ['o*' 'two']
149
pattern[1] = ['three' 'four']
150
0 0 two one}]
151
152
glob-parse 114 o*,two one [string map [list \r\n \n] \
153
{SQL expression: (x GLOB 'o*' OR x GLOB 'two')
154
pattern[0] = [o*]
155
pattern[1] = [two]
156
1 1 one}]
157
158
glob-parse 115 "o*,two three,four" "one two" [string map [list \r\n \n] \
159
{SQL expression: (x GLOB 'o*' OR x GLOB 'two' OR x GLOB 'three' OR x GLOB 'four')
160
pattern[0] = [o*]
161
pattern[1] = [two]
162
pattern[2] = [three]
163
pattern[3] = [four]
164
1 1 one two}]
165
166
glob-parse 116 'o*,two' one [string map [list \r\n \n] \
167
{SQL expression: (x GLOB 'o*,two')
168
pattern[0] = [o*,two]
169
0 0 one}]
170
171
glob-parse 117 'o*,two' one,two [string map [list \r\n \n] \
172
{SQL expression: (x GLOB 'o*,two')
173
pattern[0] = [o*,two]
174
1 1 one,two}]
175
176
glob-parse 118 "'o*,two three,four'" "one two three,four" \
177
[string map [list \r\n \n] \
178
{SQL expression: (x GLOB 'o*,two three,four')
179
pattern[0] = [o*,two three,four]
180
0 0 one two three,four}]
181
182
glob-parse 119 "'o*,two three,four'" "one,two three,four" \
183
[string map [list \r\n \n] \
184
{SQL expression: (x GLOB 'o*,two three,four')
185
pattern[0] = [o*,two three,four]
186
1 1 one,two three,four}]
187
188
###############################################################################
189
190
test_cleanup
191

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button