Statistiques
| Révision :

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

Historique | Voir | Annoter | Télécharger (21,1 ko)

1 728 mdecorde
Name "NSIS StrFunc Example"
2 728 mdecorde
OutFile "StrFunc.exe"
3 728 mdecorde
ShowInstDetails show
4 728 mdecorde
ShowUninstDetails show
5 728 mdecorde
XPStyle on
6 728 mdecorde
RequestExecutionLevel user
7 728 mdecorde
8 728 mdecorde
!include "StrFunc.nsh"
9 728 mdecorde
10 728 mdecorde
# Declare used functions
11 728 mdecorde
${StrCase}
12 728 mdecorde
${StrClb}
13 728 mdecorde
${StrIOToNSIS}
14 728 mdecorde
${StrLoc}
15 728 mdecorde
${StrNSISToIO}
16 728 mdecorde
${StrRep}
17 728 mdecorde
${StrStr}
18 728 mdecorde
${StrStrAdv}
19 728 mdecorde
${StrTok}
20 728 mdecorde
${StrTrimNewLines}
21 728 mdecorde
${StrSort}
22 728 mdecorde
23 728 mdecorde
${UnStrCase}
24 728 mdecorde
${UnStrClb}
25 728 mdecorde
${UnStrIOToNSIS}
26 728 mdecorde
${UnStrLoc}
27 728 mdecorde
${UnStrNSISToIO}
28 728 mdecorde
${UnStrRep}
29 728 mdecorde
${UnStrStr}
30 728 mdecorde
${UnStrStrAdv}
31 728 mdecorde
${UnStrTok}
32 728 mdecorde
${UnStrTrimNewLines}
33 728 mdecorde
${UnStrSort}
34 728 mdecorde
35 2956 mdecorde
36 2956 mdecorde
Var SFPass
37 2956 mdecorde
Var SFTotl
38 2956 mdecorde
!macro EndStrFuncTestEx lbl name
39 2956 mdecorde
  IfErrors ${lbl}
40 2956 mdecorde
  DetailPrint "PASSED ${name} test"
41 2956 mdecorde
  IntOp $SFPass $SFPass + 1
42 2956 mdecorde
  IntOp $SFTotl $SFTotl + 1
43 2956 mdecorde
  Goto +3
44 2956 mdecorde
${lbl}:
45 2956 mdecorde
  DetailPrint "FAILED ${name} test"
46 2956 mdecorde
  IntOp $SFTotl $SFTotl + 1
47 2956 mdecorde
!macroend
48 2956 mdecorde
!macro EndStrFuncTest name
49 2956 mdecorde
  !insertmacro EndStrFuncTestEx "${name}error" "${name}"
50 2956 mdecorde
!macroend
51 2956 mdecorde
52 2956 mdecorde
CompletedText "Passed $SFPass of $SFTotl tests"
53 2956 mdecorde
!macro CompletedAllTests
54 2956 mdecorde
  StrCmp $SFPass $SFTotl +2
55 2956 mdecorde
    SetErrorLevel 42
56 2956 mdecorde
!macroend
57 2956 mdecorde
58 728 mdecorde
!macro StackVerificationStart
59 728 mdecorde
  StrCpy $0 S0
60 728 mdecorde
  StrCpy $1 S1
61 728 mdecorde
  StrCpy $2 S2
62 728 mdecorde
  StrCpy $3 S3
63 728 mdecorde
  StrCpy $4 S4
64 728 mdecorde
  StrCpy $5 S5
65 728 mdecorde
  StrCpy $6 S6
66 728 mdecorde
  StrCpy $7 S7
67 728 mdecorde
  StrCpy $8 S8
68 728 mdecorde
  StrCpy $9 S9
69 728 mdecorde
  StrCpy $R0 SR0
70 728 mdecorde
  StrCpy $R1 SR1
71 728 mdecorde
  StrCpy $R2 SR2
72 728 mdecorde
  StrCpy $R3 SR3
73 728 mdecorde
  StrCpy $R4 SR4
74 728 mdecorde
  StrCpy $R5 SR5
75 728 mdecorde
  StrCpy $R6 SR6
76 728 mdecorde
  StrCpy $R7 SR7
77 728 mdecorde
  StrCpy $R8 SR8
78 728 mdecorde
  StrCpy $R9 SR9
79 728 mdecorde
!macroend
80 728 mdecorde
81 728 mdecorde
!macro StackVerificationEnd
82 728 mdecorde
  ClearErrors
83 728 mdecorde
  ${If} $1 != "S1"
84 728 mdecorde
  ${OrIf} $2 != "S2"
85 728 mdecorde
  ${OrIf} $3 != "S3"
86 728 mdecorde
  ${OrIf} $4 != "S4"
87 728 mdecorde
  ${OrIf} $5 != "S5"
88 728 mdecorde
  ${OrIf} $6 != "S6"
89 728 mdecorde
  ${OrIf} $7 != "S7"
90 728 mdecorde
  ${OrIf} $8 != "S8"
91 728 mdecorde
  ${OrIf} $9 != "S9"
92 728 mdecorde
  ${OrIf} $R0 != "SR0"
93 728 mdecorde
  ${OrIf} $R1 != "SR1"
94 728 mdecorde
  ${OrIf} $R2 != "SR2"
95 728 mdecorde
  ${OrIf} $R3 != "SR3"
96 728 mdecorde
  ${OrIf} $R4 != "SR4"
97 728 mdecorde
  ${OrIf} $R5 != "SR5"
98 728 mdecorde
  ${OrIf} $R6 != "SR6"
99 728 mdecorde
  ${OrIf} $R7 != "SR7"
100 728 mdecorde
  ${OrIf} $R8 != "SR8"
101 728 mdecorde
  ${OrIf} $R9 != "SR9"
102 728 mdecorde
    SetErrors
103 728 mdecorde
  ${EndIf}
104 728 mdecorde
!macroend
105 728 mdecorde
106 728 mdecorde
Section
107 728 mdecorde
108 728 mdecorde
  # Test case conversion
109 728 mdecorde
  !insertmacro StackVerificationStart
110 728 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." ""
111 728 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
112 728 mdecorde
  ${StrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
113 728 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
114 728 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "L"
115 728 mdecorde
  StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
116 728 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "U"
117 728 mdecorde
  StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
118 728 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "T"
119 728 mdecorde
  StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
120 728 mdecorde
  ${StrCase} $0 "This is just an example. A very simple one." "<>"
121 728 mdecorde
  StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
122 728 mdecorde
  ${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
123 728 mdecorde
  StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
124 728 mdecorde
  ${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
125 728 mdecorde
  StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
126 728 mdecorde
  ${StrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
127 728 mdecorde
  StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
128 728 mdecorde
  !insertmacro StackVerificationEnd
129 2956 mdecorde
  !insertmacro EndStrFuncTest StrCase
130 728 mdecorde
131 728 mdecorde
  # Test clipboard function
132 728 mdecorde
  !insertmacro StackVerificationStart
133 2956 mdecorde
  !verbose push 4
134 728 mdecorde
  ${StrClb} $0 "StrFunc clipboard test" ">"
135 2956 mdecorde
  !verbose pop
136 728 mdecorde
  StrCmp $0 "" 0 strclberror
137 728 mdecorde
  ${StrClb} $0 "StrFunc clipboard test #2" "<>"
138 728 mdecorde
  StrCmp $0 "StrFunc clipboard test" 0 strclberror
139 728 mdecorde
  ${StrClb} $0 "" "<"
140 728 mdecorde
  StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
141 728 mdecorde
  ${StrClb} $0 "" ""
142 728 mdecorde
  StrCmp $0 "" 0 strclberror
143 728 mdecorde
  !insertmacro StackVerificationEnd
144 2956 mdecorde
  !insertmacro EndStrFuncTest StrClb
145 728 mdecorde
146 728 mdecorde
  # Test IO functions
147 728 mdecorde
  !insertmacro StackVerificationStart
148 728 mdecorde
  !macro testio str
149 728 mdecorde
  ${StrNSISToIO} $0 "${str}"
150 728 mdecorde
  ${StrIOToNSIS} $0 $0
151 728 mdecorde
  StrCmp $0 "${str}" 0 ioerror
152 728 mdecorde
  !macroend
153 728 mdecorde
  !insertmacro testio "$\rtest$\n"
154 728 mdecorde
  !insertmacro testio "test$\n"
155 728 mdecorde
  !insertmacro testio "$\rtest"
156 728 mdecorde
  !insertmacro testio "test"
157 728 mdecorde
  !insertmacro testio "$\r\$\t$\n"
158 728 mdecorde
  !insertmacro testio "$\r \ $\t $\n $$"
159 728 mdecorde
  !insertmacro testio ""
160 728 mdecorde
  !insertmacro testio " "
161 728 mdecorde
  !insertmacro StackVerificationEnd
162 2956 mdecorde
  !insertmacro EndStrFuncTestEx ioerror "StrNSISToIO/StrIOToNSIS"
163 2956 mdecorde
164 728 mdecorde
  # Test string search functions
165 728 mdecorde
  !insertmacro StackVerificationStart
166 728 mdecorde
  ${StrLoc} $0 "This is just an example" "just" "<"
167 728 mdecorde
  StrCmp $0 "11" 0 strlocerror
168 728 mdecorde
  ${StrLoc} $0 a abc <
169 728 mdecorde
  StrCmp $0 "" 0 strlocerror
170 728 mdecorde
  ${StrLoc} $0 a abc >
171 728 mdecorde
  StrCmp $0 "" 0 strlocerror
172 728 mdecorde
  ${StrLoc} $0 abc a >
173 728 mdecorde
  StrCmp $0 "0" 0 strlocerror
174 728 mdecorde
  ${StrLoc} $0 abc b >
175 728 mdecorde
  StrCmp $0 "1" 0 strlocerror
176 728 mdecorde
  ${StrLoc} $0 abc c >
177 728 mdecorde
  StrCmp $0 "2" 0 strlocerror
178 728 mdecorde
  ${StrLoc} $0 abc a <
179 728 mdecorde
  StrCmp $0 "2" 0 strlocerror
180 728 mdecorde
  ${StrLoc} $0 abc b <
181 728 mdecorde
  StrCmp $0 "1" 0 strlocerror
182 728 mdecorde
  ${StrLoc} $0 abc c <
183 728 mdecorde
  StrCmp $0 "0" 0 strlocerror
184 728 mdecorde
  ${StrLoc} $0 abc d <
185 728 mdecorde
  StrCmp $0 "" 0 strlocerror
186 728 mdecorde
  !insertmacro StackVerificationEnd
187 2956 mdecorde
  !insertmacro EndStrFuncTest StrLoc
188 728 mdecorde
189 728 mdecorde
  # Test string replacement
190 728 mdecorde
  !insertmacro StackVerificationStart
191 728 mdecorde
  ${StrRep} $0 "This is just an example" "an" "one"
192 728 mdecorde
  StrCmp $0 "This is just one example" 0 strreperror
193 728 mdecorde
  ${StrRep} $0 "test... test... 1 2 3..." "test" "testing"
194 728 mdecorde
  StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
195 728 mdecorde
  ${StrRep} $0 "" "test" "testing"
196 728 mdecorde
  StrCmp $0 "" 0 strreperror
197 728 mdecorde
  ${StrRep} $0 "test" "test" "testing"
198 728 mdecorde
  StrCmp $0 "testing" 0 strreperror
199 728 mdecorde
  ${StrRep} $0 "test" "test" ""
200 728 mdecorde
  StrCmp $0 "" 0 strreperror
201 728 mdecorde
  ${StrRep} $0 "test" "" "abc"
202 728 mdecorde
  StrCmp $0 "test" 0 strreperror
203 728 mdecorde
  ${StrRep} $0 "test" "" ""
204 728 mdecorde
  StrCmp $0 "test" 0 strreperror
205 728 mdecorde
  !insertmacro StackVerificationEnd
206 2956 mdecorde
  !insertmacro EndStrFuncTest StrRep
207 728 mdecorde
208 728 mdecorde
  # Test sorting
209 728 mdecorde
  !insertmacro StackVerificationStart
210 728 mdecorde
  ${StrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
211 728 mdecorde
  StrCmp $0 "This is an exam" 0 strsorterror
212 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
213 728 mdecorde
  StrCmp $0 "just" 0 strsorterror
214 728 mdecorde
  ${StrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
215 728 mdecorde
  StrCmp $0 "This is just an example" 0 strsorterror
216 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
217 728 mdecorde
  StrCmp $0 "just an example" 0 strsorterror
218 728 mdecorde
  ${StrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
219 728 mdecorde
  StrCmp $0 "This is just" 0 strsorterror
220 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
221 728 mdecorde
  StrCmp $0 "just" 0 strsorterror
222 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
223 728 mdecorde
  StrCmp $0 "This" 0 strsorterror
224 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
225 728 mdecorde
  StrCmp $0 "example" 0 strsorterror
226 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
227 728 mdecorde
  StrCmp $0 " examp" 0 strsorterror
228 728 mdecorde
  ${StrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
229 728 mdecorde
  StrCmp $0 "error" 0 strsorterror
230 728 mdecorde
  ${StrSort} $0 "" " " "something" " " "0" "1" "0"
231 728 mdecorde
  StrCmp $0 "" 0 strsorterror
232 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "j" " " "" "" ""
233 728 mdecorde
  StrCmp $0 " just " 0 strsorterror
234 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
235 728 mdecorde
  StrCmp $0 " ust " 0 strsorterror
236 728 mdecorde
  ${StrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
237 728 mdecorde
  StrCmp $0 "This is ust an example" 0 strsorterror
238 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
239 728 mdecorde
  StrCmp $0 " jt an example" 0 strsorterror
240 728 mdecorde
  ${StrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
241 728 mdecorde
  StrCmp $0 "This is jst " 0 strsorterror
242 728 mdecorde
  ${StrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
243 728 mdecorde
  StrCmp $0 "  " 0 strsorterror
244 728 mdecorde
  ${StrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
245 728 mdecorde
  StrCmp $0 " rror " 0 strsorterror
246 728 mdecorde
  ${StrSort} $0 "" " " "something" " " "1" "0" "1"
247 728 mdecorde
  StrCmp $0 "" 0 strsorterror
248 728 mdecorde
  !insertmacro StackVerificationEnd
249 2956 mdecorde
  !insertmacro EndStrFuncTest StrSort
250 728 mdecorde
251 728 mdecorde
  !insertmacro StackVerificationStart
252 728 mdecorde
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
253 728 mdecorde
  StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
254 728 mdecorde
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
255 728 mdecorde
  StrCmp $0 "" 0 strstrerror
256 728 mdecorde
  ${StrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
257 728 mdecorde
  StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
258 728 mdecorde
  ${StrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
259 728 mdecorde
  StrCmp $0 "" 0 strstrerror
260 728 mdecorde
  !insertmacro StackVerificationEnd
261 2956 mdecorde
  !insertmacro EndStrFuncTest StrStr
262 728 mdecorde
263 728 mdecorde
  !insertmacro StackVerificationStart
264 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
265 728 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
266 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
267 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
268 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
269 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
270 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
271 728 mdecorde
  StrCmp $0 "" 0 strstradverror
272 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
273 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
274 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
275 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
276 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
277 728 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
278 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
279 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
280 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
281 728 mdecorde
  StrCmp $0 "" 0 strstradverror
282 728 mdecorde
  ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
283 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
284 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
285 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
286 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
287 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
288 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
289 728 mdecorde
  StrCmp $0 "" 0 strstradverror
290 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
291 728 mdecorde
  StrCmp $0 "" 0 strstradverror
292 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
293 728 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
294 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
295 728 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
296 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
297 728 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
298 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
299 728 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
300 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
301 728 mdecorde
  StrCmp $0 "" 0 strstradverror
302 728 mdecorde
  ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
303 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
304 728 mdecorde
  !insertmacro StackVerificationEnd
305 2956 mdecorde
  !insertmacro EndStrFuncTest StrStrAdv
306 728 mdecorde
307 728 mdecorde
  # Test tokenizer
308 728 mdecorde
  !insertmacro StackVerificationStart
309 728 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "4" "1"
310 728 mdecorde
  StrCmp $0 "not" 0 strtokerror
311 728 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "4" "0"
312 728 mdecorde
  StrCmp $0 "is" 0 strtokerror
313 728 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "152" "0"
314 728 mdecorde
  StrCmp $0 "" 0 strtokerror
315 728 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "" "0"
316 728 mdecorde
  StrCmp $0 "example" 0 strtokerror
317 728 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "L" "0"
318 728 mdecorde
  StrCmp $0 "example" 0 strtokerror
319 728 mdecorde
  ${StrTok} $0 "This is, or is not, just an example" " ," "0" "0"
320 728 mdecorde
  StrCmp $0 "This" 0 strtokerror
321 728 mdecorde
  !insertmacro StackVerificationEnd
322 2956 mdecorde
  !insertmacro EndStrFuncTest StrTok
323 728 mdecorde
324 728 mdecorde
  # Test trim new lines
325 728 mdecorde
  !insertmacro StackVerificationStart
326 728 mdecorde
  ${StrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
327 728 mdecorde
  StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
328 728 mdecorde
  !insertmacro StackVerificationEnd
329 2956 mdecorde
  !insertmacro EndStrFuncTest StrTrimNewlines
330 728 mdecorde
331 2956 mdecorde
  InitPluginsDir
332 2956 mdecorde
  WriteUninstaller $PluginsDir\UnStrFunc.exe
333 2956 mdecorde
  ExecWait '"$PluginsDir\UnStrFunc.exe" _?=$PluginsDir'
334 728 mdecorde
335 2956 mdecorde
  !insertmacro CompletedAllTests
336 728 mdecorde
SectionEnd
337 728 mdecorde
338 728 mdecorde
Section Uninstall
339 728 mdecorde
340 728 mdecorde
  # Test case conversion
341 728 mdecorde
  !insertmacro StackVerificationStart
342 728 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." ""
343 728 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
344 728 mdecorde
  ${UnStrCase} $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S"
345 728 mdecorde
  StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror
346 728 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "L"
347 728 mdecorde
  StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror
348 728 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "U"
349 728 mdecorde
  StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror
350 728 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "T"
351 728 mdecorde
  StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror
352 728 mdecorde
  ${UnStrCase} $0 "This is just an example. A very simple one." "<>"
353 728 mdecorde
  StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror
354 728 mdecorde
  ${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S"
355 728 mdecorde
  StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
356 728 mdecorde
  ${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>"
357 728 mdecorde
  StrCmp $0 "123456789abcdefghijklmnopqrstuvwxyz!@#%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ-_=+[]{};:,./<>?" 0 strcaseerror
358 728 mdecorde
  ${UnStrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S"
359 728 mdecorde
  StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
360 728 mdecorde
  !insertmacro StackVerificationEnd
361 2956 mdecorde
  !insertmacro EndStrFuncTest StrCase
362 728 mdecorde
363 728 mdecorde
  # Test clipboard function
364 728 mdecorde
  !insertmacro StackVerificationStart
365 728 mdecorde
  ${UnStrClb} $0 "StrFunc clipboard test" ">"
366 728 mdecorde
  StrCmp $0 "" 0 strclberror
367 728 mdecorde
  ${UnStrClb} $0 "StrFunc clipboard test #2" "<>"
368 728 mdecorde
  StrCmp $0 "StrFunc clipboard test" 0 strclberror
369 728 mdecorde
  ${UnStrClb} $0 "" "<"
370 728 mdecorde
  StrCmp $0 "StrFunc clipboard test #2" 0 strclberror
371 728 mdecorde
  ${UnStrClb} $0 "" ""
372 728 mdecorde
  StrCmp $0 "" 0 strclberror
373 728 mdecorde
  !insertmacro StackVerificationEnd
374 2956 mdecorde
  !insertmacro EndStrFuncTest StrClb
375 728 mdecorde
376 728 mdecorde
  # Test IO functions
377 728 mdecorde
  !insertmacro StackVerificationStart
378 728 mdecorde
  !macro untestio str
379 728 mdecorde
  ${UnStrNSISToIO} $0 "${str}"
380 728 mdecorde
  ${UnStrIOToNSIS} $0 $0
381 728 mdecorde
  StrCmp $0 "${str}" 0 ioerror
382 728 mdecorde
  !macroend
383 728 mdecorde
  !insertmacro untestio "$\rtest$\n"
384 728 mdecorde
  !insertmacro untestio "test$\n"
385 728 mdecorde
  !insertmacro untestio "$\rtest"
386 728 mdecorde
  !insertmacro untestio "test"
387 728 mdecorde
  !insertmacro untestio "$\r\$\t$\n"
388 728 mdecorde
  !insertmacro untestio "$\r \ $\t $\n $$"
389 728 mdecorde
  !insertmacro untestio ""
390 728 mdecorde
  !insertmacro untestio " "
391 728 mdecorde
  !insertmacro StackVerificationEnd
392 2956 mdecorde
  !insertmacro EndStrFuncTestEx ioerror "StrNSISToIO/StrIOToNSIS"
393 728 mdecorde
394 728 mdecorde
  # Test string search functions
395 728 mdecorde
  !insertmacro StackVerificationStart
396 728 mdecorde
  ${UnStrLoc} $0 "This is just an example" "just" "<"
397 728 mdecorde
  StrCmp $0 "11" 0 strlocerror
398 728 mdecorde
  ${UnStrLoc} $0 a abc <
399 728 mdecorde
  StrCmp $0 "" 0 strlocerror
400 728 mdecorde
  ${UnStrLoc} $0 a abc >
401 728 mdecorde
  StrCmp $0 "" 0 strlocerror
402 728 mdecorde
  ${UnStrLoc} $0 abc a >
403 728 mdecorde
  StrCmp $0 "0" 0 strlocerror
404 728 mdecorde
  ${UnStrLoc} $0 abc b >
405 728 mdecorde
  StrCmp $0 "1" 0 strlocerror
406 728 mdecorde
  ${UnStrLoc} $0 abc c >
407 728 mdecorde
  StrCmp $0 "2" 0 strlocerror
408 728 mdecorde
  ${UnStrLoc} $0 abc a <
409 728 mdecorde
  StrCmp $0 "2" 0 strlocerror
410 728 mdecorde
  ${UnStrLoc} $0 abc b <
411 728 mdecorde
  StrCmp $0 "1" 0 strlocerror
412 728 mdecorde
  ${UnStrLoc} $0 abc c <
413 728 mdecorde
  StrCmp $0 "0" 0 strlocerror
414 728 mdecorde
  ${UnStrLoc} $0 abc d <
415 728 mdecorde
  StrCmp $0 "" 0 strlocerror
416 728 mdecorde
  !insertmacro StackVerificationEnd
417 2956 mdecorde
  !insertmacro EndStrFuncTest StrLoc
418 728 mdecorde
419 728 mdecorde
  # Test string replacement
420 728 mdecorde
  !insertmacro StackVerificationStart
421 728 mdecorde
  ${UnStrRep} $0 "This is just an example" "an" "one"
422 728 mdecorde
  StrCmp $0 "This is just one example" 0 strreperror
423 728 mdecorde
  ${UnStrRep} $0 "test... test... 1 2 3..." "test" "testing"
424 728 mdecorde
  StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
425 728 mdecorde
  ${UnStrRep} $0 "" "test" "testing"
426 728 mdecorde
  StrCmp $0 "" 0 strreperror
427 728 mdecorde
  ${UnStrRep} $0 "test" "test" "testing"
428 728 mdecorde
  StrCmp $0 "testing" 0 strreperror
429 728 mdecorde
  ${UnStrRep} $0 "test" "test" ""
430 728 mdecorde
  StrCmp $0 "" 0 strreperror
431 728 mdecorde
  ${UnStrRep} $0 "test" "" "abc"
432 728 mdecorde
  StrCmp $0 "test" 0 strreperror
433 728 mdecorde
  ${UnStrRep} $0 "test" "" ""
434 728 mdecorde
  StrCmp $0 "test" 0 strreperror
435 728 mdecorde
  !insertmacro StackVerificationEnd
436 2956 mdecorde
  !insertmacro EndStrFuncTest StrRep
437 728 mdecorde
438 728 mdecorde
  # Test sorting
439 728 mdecorde
  !insertmacro StackVerificationStart
440 728 mdecorde
  ${UnStrSort} $0 "This is just an example" "" " just" "ple" "0" "0" "0"
441 728 mdecorde
  StrCmp $0 "This is an exam" 0 strsorterror
442 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "j" " " "0" "" "0"
443 728 mdecorde
  StrCmp $0 "just" 0 strsorterror
444 728 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "1" "0"
445 728 mdecorde
  StrCmp $0 "This is just an example" 0 strsorterror
446 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "us" "" "0" "1" "0"
447 728 mdecorde
  StrCmp $0 "just an example" 0 strsorterror
448 728 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "1" "0"
449 728 mdecorde
  StrCmp $0 "This is just" 0 strsorterror
450 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "just" " " "0" "1" "0"
451 728 mdecorde
  StrCmp $0 "just" 0 strsorterror
452 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "t" " " "0" "1" "0"
453 728 mdecorde
  StrCmp $0 "This" 0 strsorterror
454 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "le" " " "0" "1" "0"
455 728 mdecorde
  StrCmp $0 "example" 0 strsorterror
456 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "le" " " "1" "0" "0"
457 728 mdecorde
  StrCmp $0 " examp" 0 strsorterror
458 728 mdecorde
  ${UnStrSort} $0 "an error has occurred" " " "e" " " "0" "1" "0"
459 728 mdecorde
  StrCmp $0 "error" 0 strsorterror
460 728 mdecorde
  ${UnStrSort} $0 "" " " "something" " " "0" "1" "0"
461 728 mdecorde
  StrCmp $0 "" 0 strsorterror
462 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "j" " " "" "" ""
463 728 mdecorde
  StrCmp $0 " just " 0 strsorterror
464 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "j" " " "1" "0" "1"
465 728 mdecorde
  StrCmp $0 " ust " 0 strsorterror
466 728 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "j" "" "0" "0" "1"
467 728 mdecorde
  StrCmp $0 "This is ust an example" 0 strsorterror
468 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "us" "" "1" "0" "0"
469 728 mdecorde
  StrCmp $0 " jt an example" 0 strsorterror
470 728 mdecorde
  ${UnStrSort} $0 "This is just an example" "" "u" " " "0" "0" "1"
471 728 mdecorde
  StrCmp $0 "This is jst " 0 strsorterror
472 728 mdecorde
  ${UnStrSort} $0 "This is just an example" " " "just" " " "1" "0" "1"
473 728 mdecorde
  StrCmp $0 "  " 0 strsorterror
474 728 mdecorde
  ${UnStrSort} $0 "an error has occurred" " " "e" "h" "1" "0" "0"
475 728 mdecorde
  StrCmp $0 " rror " 0 strsorterror
476 728 mdecorde
  ${UnStrSort} $0 "" " " "something" " " "1" "0" "1"
477 728 mdecorde
  StrCmp $0 "" 0 strsorterror
478 728 mdecorde
  !insertmacro StackVerificationEnd
479 2956 mdecorde
  !insertmacro EndStrFuncTest StrSort
480 728 mdecorde
481 728 mdecorde
  !insertmacro StackVerificationStart
482 728 mdecorde
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
483 728 mdecorde
  StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
484 728 mdecorde
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
485 728 mdecorde
  StrCmp $0 "" 0 strstrerror
486 728 mdecorde
  ${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
487 728 mdecorde
  StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
488 728 mdecorde
  ${UnStrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
489 728 mdecorde
  StrCmp $0 "" 0 strstrerror
490 728 mdecorde
  !insertmacro StackVerificationEnd
491 2956 mdecorde
  !insertmacro EndStrFuncTest StrStr
492 728 mdecorde
493 728 mdecorde
  !insertmacro StackVerificationStart
494 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0"
495 728 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
496 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0"
497 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
498 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0"
499 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
500 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0"
501 728 mdecorde
  StrCmp $0 "" 0 strstradverror
502 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0"
503 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
504 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0"
505 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
506 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0"
507 728 mdecorde
  StrCmp $0 "abcabcabc" 0 strstradverror
508 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0"
509 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
510 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0"
511 728 mdecorde
  StrCmp $0 "" 0 strstradverror
512 728 mdecorde
  ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0"
513 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
514 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1"
515 728 mdecorde
  StrCmp $0 "abcabc" 0 strstradverror
516 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1"
517 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
518 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1"
519 728 mdecorde
  StrCmp $0 "" 0 strstradverror
520 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1"
521 728 mdecorde
  StrCmp $0 "" 0 strstradverror
522 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1"
523 728 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
524 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1"
525 728 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
526 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1"
527 728 mdecorde
  StrCmp $0 "ABCabcabc" 0 strstradverror
528 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1"
529 728 mdecorde
  StrCmp $0 "ABCabc" 0 strstradverror
530 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1"
531 728 mdecorde
  StrCmp $0 "" 0 strstradverror
532 728 mdecorde
  ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1"
533 728 mdecorde
  StrCmp $0 "abc" 0 strstradverror
534 728 mdecorde
  !insertmacro StackVerificationEnd
535 2956 mdecorde
  !insertmacro EndStrFuncTest StrStrAdv
536 728 mdecorde
537 728 mdecorde
  # Test tokenizer
538 728 mdecorde
  !insertmacro StackVerificationStart
539 728 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "1"
540 728 mdecorde
  StrCmp $0 "not" 0 strtokerror
541 728 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "4" "0"
542 728 mdecorde
  StrCmp $0 "is" 0 strtokerror
543 728 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "152" "0"
544 728 mdecorde
  StrCmp $0 "" 0 strtokerror
545 728 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "" "0"
546 728 mdecorde
  StrCmp $0 "example" 0 strtokerror
547 728 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "L" "0"
548 728 mdecorde
  StrCmp $0 "example" 0 strtokerror
549 728 mdecorde
  ${UnStrTok} $0 "This is, or is not, just an example" " ," "0" "0"
550 728 mdecorde
  StrCmp $0 "This" 0 strtokerror
551 728 mdecorde
  !insertmacro StackVerificationEnd
552 2956 mdecorde
  !insertmacro EndStrFuncTest StrTok
553 728 mdecorde
554 728 mdecorde
  # Test trim new lines
555 728 mdecorde
  !insertmacro StackVerificationStart
556 728 mdecorde
  ${UnStrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
557 728 mdecorde
  StrCmp $0 "$\r$\ntest$\r$\ntest" 0 strtrimnewlineserror
558 728 mdecorde
  !insertmacro StackVerificationEnd
559 2956 mdecorde
  !insertmacro EndStrFuncTest StrTrimNewLines
560 728 mdecorde
561 2956 mdecorde
  !insertmacro CompletedAllTests
562 728 mdecorde
SectionEnd