Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Examples / StrFunc.nsi @ 2107

Historique | Voir | Annoter | Télécharger (22,2 ko)

1
Name "NSIS StrFunc Example"
2
OutFile "StrFunc.exe"
3
ShowInstDetails show
4
ShowUninstDetails show
5
XPStyle on
6
RequestExecutionLevel user
7

    
8
!include "StrFunc.nsh"
9

    
10
# Declare used functions
11
${StrCase}
12
${StrClb}
13
${StrIOToNSIS}
14
${StrLoc}
15
${StrNSISToIO}
16
${StrRep}
17
${StrStr}
18
${StrStrAdv}
19
${StrTok}
20
${StrTrimNewLines}
21
${StrSort}
22

    
23
${UnStrCase}
24
${UnStrClb}
25
${UnStrIOToNSIS}
26
${UnStrLoc}
27
${UnStrNSISToIO}
28
${UnStrRep}
29
${UnStrStr}
30
${UnStrStrAdv}
31
${UnStrTok}
32
${UnStrTrimNewLines}
33
${UnStrSort}
34

    
35
!macro StackVerificationStart
36
  StrCpy $0 S0
37
  StrCpy $1 S1
38
  StrCpy $2 S2
39
  StrCpy $3 S3
40
  StrCpy $4 S4
41
  StrCpy $5 S5
42
  StrCpy $6 S6
43
  StrCpy $7 S7
44
  StrCpy $8 S8
45
  StrCpy $9 S9
46
  StrCpy $R0 SR0
47
  StrCpy $R1 SR1
48
  StrCpy $R2 SR2
49
  StrCpy $R3 SR3
50
  StrCpy $R4 SR4
51
  StrCpy $R5 SR5
52
  StrCpy $R6 SR6
53
  StrCpy $R7 SR7
54
  StrCpy $R8 SR8
55
  StrCpy $R9 SR9
56
!macroend
57

    
58
!macro StackVerificationEnd
59
  ClearErrors
60
  ${If} $1 != "S1"
61
  ${OrIf} $2 != "S2"
62
  ${OrIf} $3 != "S3"
63
  ${OrIf} $4 != "S4"
64
  ${OrIf} $5 != "S5"
65
  ${OrIf} $6 != "S6"
66
  ${OrIf} $7 != "S7"
67
  ${OrIf} $8 != "S8"
68
  ${OrIf} $9 != "S9"
69
  ${OrIf} $R0 != "SR0"
70
  ${OrIf} $R1 != "SR1"
71
  ${OrIf} $R2 != "SR2"
72
  ${OrIf} $R3 != "SR3"
73
  ${OrIf} $R4 != "SR4"
74
  ${OrIf} $R5 != "SR5"
75
  ${OrIf} $R6 != "SR6"
76
  ${OrIf} $R7 != "SR7"
77
  ${OrIf} $R8 != "SR8"
78
  ${OrIf} $R9 != "SR9"
79
    SetErrors
80
  ${EndIf}
81
!macroend
82

    
83
Section
84

    
85
  # Test case conversion
86
  !insertmacro StackVerificationStart
87
  ${StrCase} $0 "This is just an example. A very simple one." ""
88
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
89
  ${StrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
90
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
91
  ${StrCase} $0 "This is just an example. A very simple one." "L"
92
  StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
93
  ${StrCase} $0 "This is just an example. A very simple one." "U"
94
  StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
95
  ${StrCase} $0 "This is just an example. A very simple one." "T"
96
  StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
97
  ${StrCase} $0 "This is just an example. A very simple one." "<>"
98
  StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
99
  ${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
100
  StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
101
  ${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
102
  StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
103
  ${StrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
104
  StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
105
  !insertmacro StackVerificationEnd
106
  IfErrors strcaseerror
107

    
108
  DetailPrint "PASSED StrCase test"
109
  Goto +2
110
strcaseerror:
111
  DetailPrint "FAILED StrCase test"
112

    
113
  # Test clipboard function
114
  !insertmacro StackVerificationStart
115
  ${StrClb} $0 "StrFunc clipboard test" ">"
116
  StrCmp $0 "" 0 strclberror
117
  ${StrClb} $0 "StrFunc clipboard test #2" "<>"
118
  StrCmp $0 "StrFunc clipboard test" 0 strclberror
119
  ${StrClb} $0 "" "<"
120
  StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
121
  ${StrClb} $0 "" ""
122
  StrCmp $0 "" 0 strclberror
123
  !insertmacro StackVerificationEnd
124
  IfErrors strclberror
125

    
126
  DetailPrint "PASSED StrClb test"
127
  Goto +2
128
strclberror:
129
  DetailPrint "FAILED StrClb test"
130

    
131
  # Test IO functions
132
  !insertmacro StackVerificationStart
133
  !macro testio str
134
  ${StrNSISToIO} $0 "${str}"
135
  ${StrIOToNSIS} $0 $0
136
  StrCmp $0 "${str}" 0 ioerror
137
  !macroend
138
  !insertmacro testio "$\rtest$\n"
139
  !insertmacro testio "test$\n"
140
  !insertmacro testio "$\rtest"
141
  !insertmacro testio "test"
142
  !insertmacro testio "$\r\$\t$\n"
143
  !insertmacro testio "$\r \ $\t $\n $$"
144
  !insertmacro testio ""
145
  !insertmacro testio " "
146
  !insertmacro StackVerificationEnd
147
  IfErrors ioerror
148

    
149
  DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
150
  Goto +2
151
ioerror:
152
  DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
153

    
154
  # Test string search functions
155
  !insertmacro StackVerificationStart
156
  ${StrLoc} $0 "This is just an example" "just" "<"
157
  StrCmp $0 "11" 0 strlocerror
158
  ${StrLoc} $0 a abc <
159
  StrCmp $0 "" 0 strlocerror
160
  ${StrLoc} $0 a abc >
161
  StrCmp $0 "" 0 strlocerror
162
  ${StrLoc} $0 abc a >
163
  StrCmp $0 "0" 0 strlocerror
164
  ${StrLoc} $0 abc b >
165
  StrCmp $0 "1" 0 strlocerror
166
  ${StrLoc} $0 abc c >
167
  StrCmp $0 "2" 0 strlocerror
168
  ${StrLoc} $0 abc a <
169
  StrCmp $0 "2" 0 strlocerror
170
  ${StrLoc} $0 abc b <
171
  StrCmp $0 "1" 0 strlocerror
172
  ${StrLoc} $0 abc c <
173
  StrCmp $0 "0" 0 strlocerror
174
  ${StrLoc} $0 abc d <
175
  StrCmp $0 "" 0 strlocerror
176
  !insertmacro StackVerificationEnd
177
  IfErrors strlocerror
178
  
179
  DetailPrint "PASSED StrLoc test"
180
  Goto +2
181
strlocerror:
182
  DetailPrint "FAILED StrLoc test"
183

    
184
  # Test string replacement
185
  !insertmacro StackVerificationStart
186
  ${StrRep} $0 "This is just an example" "an" "one"
187
  StrCmp $0 "This is just one example" 0 strreperror
188
  ${StrRep} $0 "test... test... 1 2 3..." "test" "testing"
189
  StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
190
  ${StrRep} $0 "" "test" "testing"
191
  StrCmp $0 "" 0 strreperror
192
  ${StrRep} $0 "test" "test" "testing"
193
  StrCmp $0 "testing" 0 strreperror
194
  ${StrRep} $0 "test" "test" ""
195
  StrCmp $0 "" 0 strreperror
196
  ${StrRep} $0 "test" "" "abc"
197
  StrCmp $0 "test" 0 strreperror
198
  ${StrRep} $0 "test" "" ""
199
  StrCmp $0 "test" 0 strreperror
200
  !insertmacro StackVerificationEnd
201
  IfErrors strreperror
202
  
203
  DetailPrint "PASSED StrRep test"
204
  Goto +2
205
strreperror:
206
  DetailPrint "FAILED StrRep test"
207

    
208
  # Test sorting
209
  !insertmacro StackVerificationStart
210
  ${StrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
211
  StrCmp $0 "This is an exam" 0 strsorterror
212
  ${StrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
213
  StrCmp $0 "just" 0 strsorterror
214
  ${StrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
215
  StrCmp $0 "This is just an example" 0 strsorterror
216
  ${StrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
217
  StrCmp $0 "just an example" 0 strsorterror
218
  ${StrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
219
  StrCmp $0 "This is just" 0 strsorterror
220
  ${StrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
221
  StrCmp $0 "just" 0 strsorterror
222
  ${StrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
223
  StrCmp $0 "This" 0 strsorterror
224
  ${StrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
225
  StrCmp $0 "example" 0 strsorterror
226
  ${StrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
227
  StrCmp $0 " examp" 0 strsorterror
228
  ${StrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
229
  StrCmp $0 "error" 0 strsorterror
230
  ${StrSort} $0 "" " " "something" " " "0" "1" "0"
231
  StrCmp $0 "" 0 strsorterror
232
  ${StrSort} $0 "This is just an example" " " "j" " " "" "" ""
233
  StrCmp $0 " just " 0 strsorterror
234
  ${StrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
235
  StrCmp $0 " ust " 0 strsorterror
236
  ${StrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
237
  StrCmp $0 "This is ust an example" 0 strsorterror
238
  ${StrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
239
  StrCmp $0 " jt an example" 0 strsorterror
240
  ${StrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
241
  StrCmp $0 "This is jst " 0 strsorterror
242
  ${StrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
243
  StrCmp $0 "  " 0 strsorterror
244
  ${StrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
245
  StrCmp $0 " rror " 0 strsorterror
246
  ${StrSort} $0 "" " " "something" " " "1" "0" "1"
247
  StrCmp $0 "" 0 strsorterror
248
  !insertmacro StackVerificationEnd
249
  IfErrors strsorterror
250
  
251
  DetailPrint "PASSED StrSort test"
252
  Goto +2
253
strsorterror:
254
  DetailPrint "FAILED StrSort test"
255

    
256
  !insertmacro StackVerificationStart
257
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
258
  StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
259
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
260
  StrCmp $0 "" 0 strstrerror
261
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
262
  StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
263
  ${StrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
264
  StrCmp $0 "" 0 strstrerror
265
  !insertmacro StackVerificationEnd
266
  IfErrors strstrerror
267
  
268
  DetailPrint "PASSED StrStr test"
269
  Goto +2
270
strstrerror:
271
  DetailPrint "FAILED StrStr test"
272

    
273
  !insertmacro StackVerificationStart
274
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
275
  StrCmp $0 "abcabcabc" 0 strstradverror
276
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
277
  StrCmp $0 "abcabc" 0 strstradverror
278
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
279
  StrCmp $0 "abc" 0 strstradverror
280
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
281
  StrCmp $0 "" 0 strstradverror
282
  ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
283
  StrCmp $0 "abcabc" 0 strstradverror
284
  ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
285
  StrCmp $0 "abc" 0 strstradverror
286
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
287
  StrCmp $0 "abcabcabc" 0 strstradverror
288
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
289
  StrCmp $0 "abcabc" 0 strstradverror
290
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
291
  StrCmp $0 "" 0 strstradverror
292
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
293
  StrCmp $0 "abc" 0 strstradverror
294
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
295
  StrCmp $0 "abcabc" 0 strstradverror
296
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
297
  StrCmp $0 "abc" 0 strstradverror
298
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
299
  StrCmp $0 "" 0 strstradverror
300
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
301
  StrCmp $0 "" 0 strstradverror
302
  ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
303
  StrCmp $0 "ABCabcabc" 0 strstradverror
304
  ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
305
  StrCmp $0 "ABCabc" 0 strstradverror
306
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
307
  StrCmp $0 "ABCabcabc" 0 strstradverror
308
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
309
  StrCmp $0 "ABCabc" 0 strstradverror
310
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
311
  StrCmp $0 "" 0 strstradverror
312
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
313
  StrCmp $0 "abc" 0 strstradverror
314
  !insertmacro StackVerificationEnd
315
  IfErrors strstradverror
316
  
317
  DetailPrint "PASSED StrStrAdv test"
318
  Goto +2
319
strstradverror:
320
  DetailPrint "FAILED StrStrAdv test"
321

    
322
  # Test tokenizer
323
  !insertmacro StackVerificationStart
324
  ${StrTok} $0 "This is, or is not, just an example" " ," "4" "1"
325
  StrCmp $0 "not" 0 strtokerror
326
  ${StrTok} $0 "This is, or is not, just an example" " ," "4" "0"
327
  StrCmp $0 "is" 0 strtokerror
328
  ${StrTok} $0 "This is, or is not, just an example" " ," "152" "0"
329
  StrCmp $0 "" 0 strtokerror
330
  ${StrTok} $0 "This is, or is not, just an example" " ," "" "0"
331
  StrCmp $0 "example" 0 strtokerror
332
  ${StrTok} $0 "This is, or is not, just an example" " ," "L" "0"
333
  StrCmp $0 "example" 0 strtokerror
334
  ${StrTok} $0 "This is, or is not, just an example" " ," "0" "0"
335
  StrCmp $0 "This" 0 strtokerror
336
  !insertmacro StackVerificationEnd
337
  IfErrors strtokerror
338
  
339
  DetailPrint "PASSED StrTok test"
340
  Goto +2
341
strtokerror:
342
  DetailPrint "FAILED StrTok test"
343

    
344
  # Test trim new lines
345
  !insertmacro StackVerificationStart
346
  ${StrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
347
  StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
348
  !insertmacro StackVerificationEnd
349
  IfErrors strtrimnewlineserror
350

    
351
  DetailPrint "PASSED StrTrimNewLines test"
352
  Goto +2
353
strtrimnewlineserror:
354
  DetailPrint "FAILED StrTrimNewLines test"
355

    
356
  WriteUninstaller $EXEDIR\UnStrFunc.exe
357
  
358
  Exec $EXEDIR\UnStrFunc.exe
359

    
360
SectionEnd
361

    
362
Section Uninstall
363

    
364
  # Test case conversion
365
  !insertmacro StackVerificationStart
366
  ${UnStrCase} $0 "This is just an example. A very simple one." ""
367
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
368
  ${UnStrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
369
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
370
  ${UnStrCase} $0 "This is just an example. A very simple one." "L"
371
  StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
372
  ${UnStrCase} $0 "This is just an example. A very simple one." "U"
373
  StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
374
  ${UnStrCase} $0 "This is just an example. A very simple one." "T"
375
  StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
376
  ${UnStrCase} $0 "This is just an example. A very simple one." "<>"
377
  StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
378
  ${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
379
  StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
380
  ${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
381
  StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
382
  ${UnStrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
383
  StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
384
  !insertmacro StackVerificationEnd
385
  IfErrors strcaseerror
386

    
387
  DetailPrint "PASSED StrCase test"
388
  Goto +2
389
strcaseerror:
390
  DetailPrint "FAILED StrCase test"
391

    
392
  # Test clipboard function
393
  !insertmacro StackVerificationStart
394
  ${UnStrClb} $0 "StrFunc clipboard test" ">"
395
  StrCmp $0 "" 0 strclberror
396
  ${UnStrClb} $0 "StrFunc clipboard test #2" "<>"
397
  StrCmp $0 "StrFunc clipboard test" 0 strclberror
398
  ${UnStrClb} $0 "" "<"
399
  StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
400
  ${UnStrClb} $0 "" ""
401
  StrCmp $0 "" 0 strclberror
402
  !insertmacro StackVerificationEnd
403
  IfErrors strclberror
404

    
405
  DetailPrint "PASSED StrClb test"
406
  Goto +2
407
strclberror:
408
  DetailPrint "FAILED StrClb test"
409

    
410
  # Test IO functions
411
  !insertmacro StackVerificationStart
412
  !macro untestio str
413
  ${UnStrNSISToIO} $0 "${str}"
414
  ${UnStrIOToNSIS} $0 $0
415
  StrCmp $0 "${str}" 0 ioerror
416
  !macroend
417
  !insertmacro untestio "$\rtest$\n"
418
  !insertmacro untestio "test$\n"
419
  !insertmacro untestio "$\rtest"
420
  !insertmacro untestio "test"
421
  !insertmacro untestio "$\r\$\t$\n"
422
  !insertmacro untestio "$\r \ $\t $\n $$"
423
  !insertmacro untestio ""
424
  !insertmacro untestio " "
425
  !insertmacro StackVerificationEnd
426
  IfErrors ioerror
427

    
428
  DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
429
  Goto +2
430
ioerror:
431
  DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
432

    
433
  # Test string search functions
434
  !insertmacro StackVerificationStart
435
  ${UnStrLoc} $0 "This is just an example" "just" "<"
436
  StrCmp $0 "11" 0 strlocerror
437
  ${UnStrLoc} $0 a abc <
438
  StrCmp $0 "" 0 strlocerror
439
  ${UnStrLoc} $0 a abc >
440
  StrCmp $0 "" 0 strlocerror
441
  ${UnStrLoc} $0 abc a >
442
  StrCmp $0 "0" 0 strlocerror
443
  ${UnStrLoc} $0 abc b >
444
  StrCmp $0 "1" 0 strlocerror
445
  ${UnStrLoc} $0 abc c >
446
  StrCmp $0 "2" 0 strlocerror
447
  ${UnStrLoc} $0 abc a <
448
  StrCmp $0 "2" 0 strlocerror
449
  ${UnStrLoc} $0 abc b <
450
  StrCmp $0 "1" 0 strlocerror
451
  ${UnStrLoc} $0 abc c <
452
  StrCmp $0 "0" 0 strlocerror
453
  ${UnStrLoc} $0 abc d <
454
  StrCmp $0 "" 0 strlocerror
455
  !insertmacro StackVerificationEnd
456
  IfErrors strlocerror
457

    
458
  DetailPrint "PASSED StrLoc test"
459
  Goto +2
460
strlocerror:
461
  DetailPrint "FAILED StrLoc test"
462

    
463
  # Test string replacement
464
  !insertmacro StackVerificationStart
465
  ${UnStrRep} $0 "This is just an example" "an" "one"
466
  StrCmp $0 "This is just one example" 0 strreperror
467
  ${UnStrRep} $0 "test... test... 1 2 3..." "test" "testing"
468
  StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
469
  ${UnStrRep} $0 "" "test" "testing"
470
  StrCmp $0 "" 0 strreperror
471
  ${UnStrRep} $0 "test" "test" "testing"
472
  StrCmp $0 "testing" 0 strreperror
473
  ${UnStrRep} $0 "test" "test" ""
474
  StrCmp $0 "" 0 strreperror
475
  ${UnStrRep} $0 "test" "" "abc"
476
  StrCmp $0 "test" 0 strreperror
477
  ${UnStrRep} $0 "test" "" ""
478
  StrCmp $0 "test" 0 strreperror
479
  !insertmacro StackVerificationEnd
480
  IfErrors strreperror
481

    
482
  DetailPrint "PASSED StrRep test"
483
  Goto +2
484
strreperror:
485
  DetailPrint "FAILED StrRep test"
486

    
487
  # Test sorting
488
  !insertmacro StackVerificationStart
489
  ${UnStrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
490
  StrCmp $0 "This is an exam" 0 strsorterror
491
  ${UnStrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
492
  StrCmp $0 "just" 0 strsorterror
493
  ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
494
  StrCmp $0 "This is just an example" 0 strsorterror
495
  ${UnStrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
496
  StrCmp $0 "just an example" 0 strsorterror
497
  ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
498
  StrCmp $0 "This is just" 0 strsorterror
499
  ${UnStrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
500
  StrCmp $0 "just" 0 strsorterror
501
  ${UnStrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
502
  StrCmp $0 "This" 0 strsorterror
503
  ${UnStrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
504
  StrCmp $0 "example" 0 strsorterror
505
  ${UnStrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
506
  StrCmp $0 " examp" 0 strsorterror
507
  ${UnStrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
508
  StrCmp $0 "error" 0 strsorterror
509
  ${UnStrSort} $0 "" " " "something" " " "0" "1" "0"
510
  StrCmp $0 "" 0 strsorterror
511
  ${UnStrSort} $0 "This is just an example" " " "j" " " "" "" ""
512
  StrCmp $0 " just " 0 strsorterror
513
  ${UnStrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
514
  StrCmp $0 " ust " 0 strsorterror
515
  ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
516
  StrCmp $0 "This is ust an example" 0 strsorterror
517
  ${UnStrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
518
  StrCmp $0 " jt an example" 0 strsorterror
519
  ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
520
  StrCmp $0 "This is jst " 0 strsorterror
521
  ${UnStrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
522
  StrCmp $0 "  " 0 strsorterror
523
  ${UnStrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
524
  StrCmp $0 " rror " 0 strsorterror
525
  ${UnStrSort} $0 "" " " "something" " " "1" "0" "1"
526
  StrCmp $0 "" 0 strsorterror
527
  !insertmacro StackVerificationEnd
528
  IfErrors strsorterror
529

    
530
  DetailPrint "PASSED StrSort test"
531
  Goto +2
532
strsorterror:
533
  DetailPrint "FAILED StrSort test"
534

    
535
  !insertmacro StackVerificationStart
536
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
537
  StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
538
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
539
  StrCmp $0 "" 0 strstrerror
540
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
541
  StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
542
  ${UnStrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
543
  StrCmp $0 "" 0 strstrerror
544
  !insertmacro StackVerificationEnd
545
  IfErrors strstrerror
546

    
547
  DetailPrint "PASSED StrStr test"
548
  Goto +2
549
strstrerror:
550
  DetailPrint "FAILED StrStr test"
551

    
552
  !insertmacro StackVerificationStart
553
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
554
  StrCmp $0 "abcabcabc" 0 strstradverror
555
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
556
  StrCmp $0 "abcabc" 0 strstradverror
557
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
558
  StrCmp $0 "abc" 0 strstradverror
559
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
560
  StrCmp $0 "" 0 strstradverror
561
  ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
562
  StrCmp $0 "abcabc" 0 strstradverror
563
  ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
564
  StrCmp $0 "abc" 0 strstradverror
565
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
566
  StrCmp $0 "abcabcabc" 0 strstradverror
567
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
568
  StrCmp $0 "abcabc" 0 strstradverror
569
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
570
  StrCmp $0 "" 0 strstradverror
571
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
572
  StrCmp $0 "abc" 0 strstradverror
573
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
574
  StrCmp $0 "abcabc" 0 strstradverror
575
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
576
  StrCmp $0 "abc" 0 strstradverror
577
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
578
  StrCmp $0 "" 0 strstradverror
579
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
580
  StrCmp $0 "" 0 strstradverror
581
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
582
  StrCmp $0 "ABCabcabc" 0 strstradverror
583
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
584
  StrCmp $0 "ABCabc" 0 strstradverror
585
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
586
  StrCmp $0 "ABCabcabc" 0 strstradverror
587
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
588
  StrCmp $0 "ABCabc" 0 strstradverror
589
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
590
  StrCmp $0 "" 0 strstradverror
591
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
592
  StrCmp $0 "abc" 0 strstradverror
593
  !insertmacro StackVerificationEnd
594
  IfErrors strstradverror
595

    
596
  DetailPrint "PASSED StrStrAdv test"
597
  Goto +2
598
strstradverror:
599
  DetailPrint "FAILED StrStrAdv test"
600

    
601
  # Test tokenizer
602
  !insertmacro StackVerificationStart
603
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "1"
604
  StrCmp $0 "not" 0 strtokerror
605
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "0"
606
  StrCmp $0 "is" 0 strtokerror
607
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "152" "0"
608
  StrCmp $0 "" 0 strtokerror
609
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "" "0"
610
  StrCmp $0 "example" 0 strtokerror
611
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "L" "0"
612
  StrCmp $0 "example" 0 strtokerror
613
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "0" "0"
614
  StrCmp $0 "This" 0 strtokerror
615
  !insertmacro StackVerificationEnd
616
  IfErrors strtokerror
617

    
618
  DetailPrint "PASSED StrTok test"
619
  Goto +2
620
strtokerror:
621
  DetailPrint "FAILED StrTok test"
622

    
623
  # Test trim new lines
624
  !insertmacro StackVerificationStart
625
  ${UnStrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
626
  StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
627
  !insertmacro StackVerificationEnd
628
  IfErrors strtrimnewlineserror
629

    
630
  DetailPrint "PASSED StrTrimNewLines test"
631
  Goto +2
632
strtrimnewlineserror:
633
  DetailPrint "FAILED StrTrimNewLines test"
634

    
635
SectionEnd