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