| | 1 | | #pragma rtGlobals=3 |
| | 2 | | #pragma rtFunctionErrors=1 |
| | 3 | | #pragma version=1.10 |
| | 4 | | #pragma TextEncoding="UTF-8" |
| | 5 | | #pragma ModuleName=IUTF_Wrapper |
| | 6 | |
|
| | 7 | | static Constant RTE_NULL_STRING = 185 |
| | 8 | |
|
| | 9 | | /// @class INFO_DOCU |
| | 10 | | /// Append information to the next assertion to print if failed |
| 195 | 11 | | static Function INFO_WRAPPER(format, strings, numbers, flags) |
| | 12 | | string format |
| | 13 | | WAVE/T strings |
| | 14 | | WAVE numbers |
| | 15 | | variable flags |
| | 16 | |
|
| 195 | 17 | | variable err, index |
| 195 | 18 | | string msg |
| 195 | 19 | | WAVE/T wvInfoMsg = IUTF_Reporting#GetInfoMsg() |
| | 20 | |
|
| 195 | 21 | | msg = IUTF_Utils_Strings#UserPrintF(format, strings, numbers, err) |
| 195 | 22 | | if(err) |
| 0 | 23 | | sprintf msg, "PrintF error \"%s\"", msg |
| 0 | 24 | | EvaluateResults(0, msg, flags, cleanupInfo = 0) |
| 0 | 25 | | return NaN |
| 195 | 26 | | endif |
| | 27 | |
|
| 195 | 28 | | index = IUTF_Utils_Vector#AddRow(wvInfoMsg) |
| 195 | 29 | | wvInfoMsg[index] = msg |
| 195 | 30 | | End |
| | 31 | |
|
| | 32 | | /// @class CDF_EMPTY_DOCU |
| | 33 | | /// Tests if the current data folder is empty |
| | 34 | | /// |
| | 35 | | /// Counted are objects with type waves, strings, variables and folders |
| 0 | 36 | | static Function CDF_EMPTY_WRAPPER(flags) |
| | 37 | | variable flags |
| | 38 | |
|
| 0 | 39 | | variable result |
| | 40 | |
|
| 0 | 41 | | IUTF_Reporting#incrAssert() |
| | 42 | |
|
| 0 | 43 | | if(shouldDoAbort()) |
| 0 | 44 | | return NaN |
| 0 | 45 | | endif |
| | 46 | |
|
| 0 | 47 | | result = IUTF_Checks#IsDataFolderEmpty(":") |
| 0 | 48 | | EvaluateResults(result, "Assumption that the current data folder is empty is", flags) |
| 0 | 49 | | End |
| | 50 | |
|
| | 51 | | /// @class TRUE_DOCU |
| | 52 | | /// Tests if var is non-zero and not "Not a Number" (NaN). |
| | 53 | | /// |
| | 54 | | /// @param var variable to test |
| 21 | 55 | | static Function TRUE_WRAPPER(var, flags) |
| | 56 | | variable var |
| | 57 | | variable flags |
| | 58 | |
|
| 21 | 59 | | variable result |
| | 60 | |
|
| 21 | 61 | | IUTF_Reporting#incrAssert() |
| | 62 | |
|
| 21 | 63 | | if(shouldDoAbort()) |
| 0 | 64 | | return NaN |
| 21 | 65 | | endif |
| | 66 | |
|
| 21 | 67 | | result = IUTF_Checks#IsTrue(var) |
| 21 | 68 | | EvaluateResults(result, num2istr(var), flags) |
| 21 | 69 | | End |
| | 70 | |
|
| | 71 | | /// @class NULL_STR_DOCU |
| | 72 | | /// Tests if str is null. |
| | 73 | | /// |
| | 74 | | /// An empty string is never null. |
| | 75 | | /// @param str string to test |
| 0 | 76 | | static Function NULL_STR_WRAPPER(str, flags) |
| | 77 | | string &str |
| | 78 | | variable flags |
| | 79 | |
|
| 0 | 80 | | variable result |
| | 81 | |
|
| 0 | 82 | | IUTF_Reporting#incrAssert() |
| | 83 | |
|
| 0 | 84 | | if(shouldDoAbort()) |
| 0 | 85 | | return NaN |
| 0 | 86 | | endif |
| | 87 | |
|
| 0 | 88 | | result = IUTF_Checks#IsNullString(str) |
| 0 | 89 | | EvaluateResults(result, "Assumption that str is null is", flags) |
| 0 | 90 | | End |
| | 91 | |
|
| | 92 | | /// @class EMPTY_STR_DOCU |
| | 93 | | /// Tests if str is empty. |
| | 94 | | /// |
| | 95 | | /// A null string is never empty. |
| | 96 | | /// @param str string to test |
| 0 | 97 | | static Function EMPTY_STR_WRAPPER(str, flags) |
| | 98 | | string &str |
| | 99 | | variable flags |
| | 100 | |
|
| 0 | 101 | | variable result |
| | 102 | |
|
| 0 | 103 | | IUTF_Reporting#incrAssert() |
| | 104 | |
|
| 0 | 105 | | if(shouldDoAbort()) |
| 0 | 106 | | return NaN |
| 0 | 107 | | endif |
| | 108 | |
|
| 0 | 109 | | result = IUTF_Checks#IsEmptyString(str) |
| 0 | 110 | | EvaluateResults(result, "Assumption that the string is empty is", flags) |
| 0 | 111 | | End |
| | 112 | |
|
| | 113 | | /// @class NON_NULL_STR_DOCU |
| | 114 | | /// Tests if str is not null. |
| | 115 | | /// |
| | 116 | | /// An empty string is always non null. |
| | 117 | | /// @param str string to test |
| 0 | 118 | | static Function NON_NULL_STR_WRAPPER(str, flags) |
| | 119 | | string &str |
| | 120 | | variable flags |
| | 121 | |
|
| 0 | 122 | | variable result |
| | 123 | |
|
| 0 | 124 | | IUTF_Reporting#incrAssert() |
| | 125 | |
|
| 0 | 126 | | if(shouldDoAbort()) |
| 0 | 127 | | return NaN |
| 0 | 128 | | endif |
| | 129 | |
|
| 0 | 130 | | result = !IUTF_Checks#IsNullString(str) |
| 0 | 131 | | EvaluateResults(result, "Assumption of the string being non null is", flags) |
| 0 | 132 | | End |
| | 133 | |
|
| | 134 | | /// @class NON_EMPTY_STR_DOCU |
| | 135 | | /// Tests if str is not empty. |
| | 136 | | /// |
| | 137 | | /// A null string is a non empty string too. |
| | 138 | | /// @param str string to test |
| 0 | 139 | | static Function NON_EMPTY_STR_WRAPPER(str, flags) |
| | 140 | | string &str |
| | 141 | | variable flags |
| | 142 | |
|
| 0 | 143 | | variable result |
| | 144 | |
|
| 0 | 145 | | IUTF_Reporting#incrAssert() |
| | 146 | |
|
| 0 | 147 | | if(shouldDoAbort()) |
| 0 | 148 | | return NaN |
| 0 | 149 | | endif |
| | 150 | |
|
| 0 | 151 | | result = !IUTF_Checks#IsEmptyString(str) |
| 0 | 152 | | EvaluateResults(result, "Assumption that the string is non empty is", flags) |
| 0 | 153 | | End |
| | 154 | |
|
| | 155 | | /// @class PROPER_STR_DOCU |
| | 156 | | /// Tests if str is a "proper" string, i.e. a string with a length larger than |
| | 157 | | /// zero. |
| | 158 | | /// |
| | 159 | | /// Neither null strings nor empty strings are proper strings. |
| | 160 | | /// @param str string to test |
| 0 | 161 | | static Function PROPER_STR_WRAPPER(str, flags) |
| | 162 | | string &str |
| | 163 | | variable flags |
| | 164 | |
|
| 0 | 165 | | variable result |
| | 166 | |
|
| 0 | 167 | | IUTF_Reporting#incrAssert() |
| | 168 | |
|
| 0 | 169 | | if(shouldDoAbort()) |
| 0 | 170 | | return NaN |
| 0 | 171 | | endif |
| | 172 | |
|
| 0 | 173 | | result = IUTF_Checks#IsProperString(str) |
| 0 | 174 | | EvaluateResults(result, "Assumption that the string is a proper string is", flags) |
| 0 | 175 | | End |
| | 176 | |
|
| | 177 | | /// @class NEQ_VAR_DOCU |
| | 178 | | /// Tests two variables for inequality |
| | 179 | | /// |
| | 180 | | /// @param var1 first variable |
| | 181 | | /// @param var2 second variable |
| 0 | 182 | | static Function NEQ_VAR_WRAPPER(var1, var2, flags) |
| | 183 | | variable var1, var2 |
| | 184 | | variable flags |
| | 185 | |
|
| 0 | 186 | | variable result |
| 0 | 187 | | string str, tmpStr1, tmpStr2 |
| | 188 | |
|
| 0 | 189 | | IUTF_Reporting#incrAssert() |
| | 190 | |
|
| 0 | 191 | | if(shouldDoAbort()) |
| 0 | 192 | | return NaN |
| 0 | 193 | | endif |
| | 194 | |
|
| 0 | 195 | | result = !IUTF_Checks#AreVariablesEqual(var1, var2) |
| 0 | 196 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var1, isDouble = 1) |
| 0 | 197 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(var2, isDouble = 1) |
| 0 | 198 | | sprintf str, "%s != %s", tmpStr1, tmpStr2 |
| 0 | 199 | | EvaluateResults(result, str, flags) |
| 0 | 200 | | End |
| | 201 | |
|
| | 202 | | /// @class NEQ_STR_DOCU |
| | 203 | | /// Compares two strings for unequality |
| | 204 | | /// |
| | 205 | | /// This doesn't check if one of the two string are null. If this function is called with a null |
| | 206 | | /// string this will throw a check assertion error. The same will happen if you call this function |
| | 207 | | /// and there is a pending code 185 runtime error. |
| | 208 | | /// |
| | 209 | | /// @param str1 first string |
| | 210 | | /// @param str2 second string |
| | 211 | | /// @param case_sensitive (optional) should the comparison be done case sensitive (1) or case insensitive (0, the defau |
| 0 | 212 | | static Function NEQ_STR_WRAPPER(str1, str2, flags, [case_sensitive]) |
| | 213 | | string &str1, &str2 |
| | 214 | | variable case_sensitive |
| | 215 | | variable flags |
| | 216 | |
|
| 0 | 217 | | variable result |
| 0 | 218 | | string str, tmpStr1, tmpStr2 |
| | 219 | |
|
| 0 | 220 | | IUTF_Reporting#incrAssert() |
| | 221 | |
|
| 0 | 222 | | if(shouldDoAbort()) |
| 0 | 223 | | return NaN |
| 0 | 224 | | endif |
| | 225 | |
|
| 0 | 226 | | if(ParamIsDefault(case_sensitive)) |
| 0 | 227 | | case_sensitive = 1 |
| 0 | 228 | | endif |
| | 229 | |
|
| 0 | 230 | | if(GetRTError(0) == RTE_NULL_STRING) |
| 0 | 231 | | IUTF_Basics#ClearRTError() |
| 0 | 232 | | str = "Null string error: One of the provided arguments could be an unsupported null string." |
| 0 | 233 | | EvaluateResults(0, str, CHECK_MODE) |
| 0 | 234 | | return NaN |
| 0 | 235 | | endif |
| | 236 | |
|
| 0 | 237 | | result = !IUTF_Checks#AreStringsEqual(str1, str2, case_sensitive) |
| 0 | 238 | | tmpStr1 = IUTF_Utils#IUTF_PrepareStringForOut(str1) |
| 0 | 239 | | tmpStr2 = IUTF_Utils#IUTF_PrepareStringForOut(str2) |
| 0 | 240 | | sprintf str, "\"%s\" != \"%s\" %s case", tmpStr1, tmpStr2, SelectString(case_sensitive, "not respecting", "respecting" |
| | 241 | |
|
| 0 | 242 | | EvaluateResults(result, str, flags) |
| 0 | 243 | | End |
| | 244 | |
|
| | 245 | | /// @class CLOSE_VAR_DOCU |
| | 246 | | /// Compares two variables and determines if they are close. |
| | 247 | | /// |
| | 248 | | /// Based on the implementation of "Floating-point comparison algorithms" in the C++ Boost unit testing framework. |
| | 249 | | /// |
| | 250 | | /// Literature:<br> |
| | 251 | | /// The art of computer programming (Vol II). Donald. E. Knuth. 0-201-89684-2. Addison-Wesley Professional; |
| | 252 | | /// 3 edition, page 234 equation (34) and (35). |
| | 253 | | /// |
| | 254 | | /// @param var1 first variable |
| | 255 | | /// @param var2 second variable |
| | 256 | | /// @param tol (optional) tolerance, defaults to 1e-8 |
| | 257 | | /// @param strong (optional) type of condition, can be 0 for weak or 1 for strong (default) |
| 0 | 258 | | static Function CLOSE_VAR_WRAPPER(var1, var2, flags, [tol, strong]) |
| | 259 | | variable var1, var2 |
| | 260 | | variable flags |
| | 261 | | variable tol |
| | 262 | | variable strong |
| | 263 | |
|
| 0 | 264 | | variable result |
| 0 | 265 | | string str, tmpStr1, tmpStr2, tmpStr3 |
| | 266 | |
|
| 0 | 267 | | IUTF_Reporting#incrAssert() |
| | 268 | |
|
| 0 | 269 | | if(shouldDoAbort()) |
| 0 | 270 | | return NaN |
| 0 | 271 | | endif |
| | 272 | |
|
| 0 | 273 | | if(ParamIsDefault(strong)) |
| 0 | 274 | | strong = CLOSE_COMPARE_STRONG |
| 0 | 275 | | endif |
| | 276 | |
|
| 0 | 277 | | if(ParamIsDefault(tol)) |
| 0 | 278 | | tol = DEFAULT_TOLERANCE |
| 0 | 279 | | endif |
| | 280 | |
|
| 0 | 281 | | result = IUTF_Checks#AreVariablesClose(var1, var2, tol, strong) |
| 0 | 282 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var1, isDouble = 1) |
| 0 | 283 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(var2, isDouble = 1) |
| 0 | 284 | | tmpStr3 = IUTF_Utils#GetNiceStringForNumber(tol, isDouble = 1) |
| 0 | 285 | | sprintf str, "%s ~ %s with %s check and tol %s", tmpStr1, tmpStr2, SelectString(strong, "weak", "strong"), tmpStr3 |
| 0 | 286 | | EvaluateResults(result, str, flags) |
| 0 | 287 | | End |
| | 288 | |
|
| | 289 | | /// @class CLOSE_CMPLX_DOCU |
| | 290 | | /// @copydoc CLOSE_VAR_DOCU |
| | 291 | | /// |
| | 292 | | /// Variant for complex numbers. |
| 0 | 293 | | static Function CLOSE_CMPLX_WRAPPER(var1, var2, flags, [tol, strong]) |
| | 294 | | variable/C var1, var2 |
| | 295 | | variable flags |
| | 296 | | variable tol |
| | 297 | | variable strong |
| | 298 | |
|
| 0 | 299 | | variable result |
| 0 | 300 | | string str, tmpStr1, tmpStr2, tmpStr3, tmpStr4, tmpStr5 |
| | 301 | |
|
| 0 | 302 | | IUTF_Reporting#incrAssert() |
| | 303 | |
|
| 0 | 304 | | if(shouldDoAbort()) |
| 0 | 305 | | return NaN |
| 0 | 306 | | endif |
| | 307 | |
|
| 0 | 308 | | if(ParamIsDefault(strong)) |
| 0 | 309 | | strong = CLOSE_COMPARE_STRONG |
| 0 | 310 | | endif |
| | 311 | |
|
| 0 | 312 | | if(ParamIsDefault(tol)) |
| 0 | 313 | | tol = DEFAULT_TOLERANCE |
| 0 | 314 | | endif |
| | 315 | |
|
| 0 | 316 | | result = IUTF_Checks#AreVariablesClose(real(var1), real(var2), tol, strong) && IUTF_Checks#AreVariablesClose(imag(var |
| 0 | 317 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(real(var1), isDouble = 1) |
| 0 | 318 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(imag(var1), isDouble = 1) |
| 0 | 319 | | tmpStr3 = IUTF_Utils#GetNiceStringForNumber(real(var2), isDouble = 1) |
| 0 | 320 | | tmpStr4 = IUTF_Utils#GetNiceStringForNumber(imag(var2), isDouble = 1) |
| 0 | 321 | | tmpStr5 = IUTF_Utils#GetNiceStringForNumber(tol, isDouble = 1) |
| 0 | 322 | | sprintf str, "(%s, %s) ~ (%s, %s) with %s check and tol %s", tmpStr1, tmpStr2, tmpStr3, tmpStr4, SelectString(strong, |
| 0 | 323 | | EvaluateResults(result, str, flags) |
| 0 | 324 | | End |
| | 325 | |
|
| | 326 | | /// @cond HIDDEN_SYMBOL |
| | 327 | | #if IgorVersion() >= 7.0 |
| | 328 | | /// @endcond |
| | 329 | |
|
| | 330 | | /// @class CLOSE_INT64_DOCU |
| | 331 | | /// Compares two int64 and determines if they are close. |
| | 332 | | /// |
| | 333 | | /// @param var1 first int64 variable |
| | 334 | | /// @param var2 second int64 variable |
| | 335 | | /// @param tol (optional) int64 tolerance, defaults to 16 |
| 0 | 336 | | static Function CLOSE_INT64_WRAPPER(int64 var1, int64 var2, variable flags, [int64 tol]) |
| 0 | 337 | | variable result |
| 0 | 338 | | string str |
| | 339 | |
|
| 0 | 340 | | IUTF_Reporting#incrAssert() |
| | 341 | |
|
| 0 | 342 | | if(shouldDoAbort()) |
| 0 | 343 | | return NaN |
| 0 | 344 | | endif |
| | 345 | |
|
| 0 | 346 | | if(ParamIsDefault(tol)) |
| 0 | 347 | | tol = DEFAULT_TOLERANCE_INT |
| 0 | 348 | | endif |
| | 349 | |
|
| 0 | 350 | | result = IUTF_Checks#AreINT64Close(var1, var2, tol) |
| 0 | 351 | | sprintf str, "%d ~ %d with tol %d", var1, var2, tol |
| 0 | 352 | | EvaluateResults(result, str, flags) |
| 0 | 353 | | End |
| | 354 | |
|
| | 355 | | /// @class CLOSE_UINT64_DOCU |
| | 356 | | /// Compares two uint64 and determines if they are close. |
| | 357 | | /// |
| | 358 | | /// @param var1 first uint64 variable |
| | 359 | | /// @param var2 second uint64 variable |
| | 360 | | /// @param tol (optional) uint64 tolerance, defaults to 16 |
| 0 | 361 | | static Function CLOSE_UINT64_WRAPPER(uint64 var1, uint64 var2, variable flags, [uint64 tol]) |
| 0 | 362 | | variable result |
| 0 | 363 | | string str |
| | 364 | |
|
| 0 | 365 | | IUTF_Reporting#incrAssert() |
| | 366 | |
|
| 0 | 367 | | if(shouldDoAbort()) |
| 0 | 368 | | return NaN |
| 0 | 369 | | endif |
| | 370 | |
|
| 0 | 371 | | if(ParamIsDefault(tol)) |
| 0 | 372 | | tol = DEFAULT_TOLERANCE_INT |
| 0 | 373 | | endif |
| | 374 | |
|
| 0 | 375 | | result = IUTF_Checks#AreUINT64Close(var1, var2, tol) |
| 0 | 376 | | sprintf str, "%d ~ %d with tol %d", var1, var2, tol |
| 0 | 377 | | EvaluateResults(result, str, flags) |
| 0 | 378 | | End |
| | 379 | |
|
| | 380 | | /// @cond HIDDEN_SYMBOL |
| | 381 | | #endif |
| | 382 | | /// @endcond |
| | 383 | |
|
| | 384 | | /// @class SMALL_VAR_DOCU |
| | 385 | | /// Tests if a variable is small using the inequality @f$ | var | < | tol | @f$ |
| | 386 | | /// |
| | 387 | | /// @param var variable |
| | 388 | | /// @param tol (optional) tolerance, defaults to 1e-8 |
| 0 | 389 | | static Function SMALL_VAR_WRAPPER(var, flags, [tol]) |
| | 390 | | variable var |
| | 391 | | variable flags |
| | 392 | | variable tol |
| | 393 | |
|
| 0 | 394 | | variable result |
| 0 | 395 | | string str, tmpStr1, tmpStr2 |
| | 396 | |
|
| 0 | 397 | | IUTF_Reporting#incrAssert() |
| | 398 | |
|
| 0 | 399 | | if(shouldDoAbort()) |
| 0 | 400 | | return NaN |
| 0 | 401 | | endif |
| | 402 | |
|
| 0 | 403 | | if(ParamIsDefault(tol)) |
| 0 | 404 | | tol = DEFAULT_TOLERANCE |
| 0 | 405 | | endif |
| | 406 | |
|
| 0 | 407 | | result = IUTF_Checks#IsVariableSmall(var, tol) |
| 0 | 408 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var, isDouble = 1) |
| 0 | 409 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(tol, isDouble = 1) |
| | 410 | |
|
| 0 | 411 | | sprintf str, "%s ~ 0 with tol %s", tmpStr1, tmpStr2 |
| 0 | 412 | | EvaluateResults(result, str, flags) |
| 0 | 413 | | End |
| | 414 | |
|
| | 415 | | /// @class SMALL_CMPLX_DOCU |
| | 416 | | /// @copydoc SMALL_VAR_DOCU |
| | 417 | | /// |
| | 418 | | /// Variant for complex numbers |
| 0 | 419 | | static Function SMALL_CMPLX_WRAPPER(var, flags, [tol]) |
| | 420 | | variable/C var |
| | 421 | | variable flags |
| | 422 | | variable tol |
| | 423 | |
|
| 0 | 424 | | variable result |
| 0 | 425 | | string str, tmpStr1, tmpStr2, tmpStr3 |
| | 426 | |
|
| 0 | 427 | | IUTF_Reporting#incrAssert() |
| | 428 | |
|
| 0 | 429 | | if(shouldDoAbort()) |
| 0 | 430 | | return NaN |
| 0 | 431 | | endif |
| | 432 | |
|
| 0 | 433 | | if(ParamIsDefault(tol)) |
| 0 | 434 | | tol = DEFAULT_TOLERANCE |
| 0 | 435 | | endif |
| | 436 | |
|
| 0 | 437 | | result = IUTF_Checks#IsVariableSmall(cabs(var), tol) |
| 0 | 438 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(real(var), isDouble = 1) |
| 0 | 439 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(imag(var), isDouble = 1) |
| 0 | 440 | | tmpStr3 = IUTF_Utils#GetNiceStringForNumber(tol, isDouble = 1) |
| 0 | 441 | | sprintf str, "(%s, %s) ~ 0 with tol %s", tmpStr1, tmpStr2, tmpStr3 |
| 0 | 442 | | EvaluateResults(result, str, flags) |
| 0 | 443 | | End |
| | 444 | |
|
| | 445 | | /// @cond HIDDEN_SYMBOL |
| | 446 | | #if IgorVersion() >= 7.0 |
| | 447 | | /// @endcond |
| | 448 | |
|
| | 449 | | /// @class SMALL_INT64_DOCU |
| | 450 | | /// Tests if a int64 variable is small using the inequality @f$ | var | < | tol | @f$ |
| | 451 | | /// |
| | 452 | | /// @param var int64 variable |
| | 453 | | /// @param tol (optional) int64 tolerance, defaults to 16 |
| 0 | 454 | | static Function SMALL_INT64_WRAPPER(int64 var, variable flags, [int64 tol]) |
| 0 | 455 | | variable result |
| 0 | 456 | | string str |
| | 457 | |
|
| 0 | 458 | | IUTF_Reporting#incrAssert() |
| | 459 | |
|
| 0 | 460 | | if(shouldDoAbort()) |
| 0 | 461 | | return NaN |
| 0 | 462 | | endif |
| | 463 | |
|
| 0 | 464 | | if(ParamIsDefault(tol)) |
| 0 | 465 | | tol = DEFAULT_TOLERANCE_INT |
| 0 | 466 | | endif |
| | 467 | |
|
| 0 | 468 | | result = IUTF_Checks#IsINT64Small(var, tol) |
| 0 | 469 | | sprintf str, "%d ~ 0 with tol %g", var, tol |
| 0 | 470 | | EvaluateResults(result, str, flags) |
| 0 | 471 | | End |
| | 472 | |
|
| | 473 | | /// @class SMALL_UINT64_DOCU |
| | 474 | | /// Tests if a uint64 variable is small using the inequality @f$ var < tol @f$ |
| | 475 | | /// |
| | 476 | | /// @param var uint64 variable |
| | 477 | | /// @param tol (optional) uint64 tolerance, defaults to 16 |
| 0 | 478 | | static Function SMALL_UINT64_WRAPPER(uint64 var, variable flags, [uint64 tol]) |
| 0 | 479 | | variable result |
| 0 | 480 | | string str |
| | 481 | |
|
| 0 | 482 | | IUTF_Reporting#incrAssert() |
| | 483 | |
|
| 0 | 484 | | if(shouldDoAbort()) |
| 0 | 485 | | return NaN |
| 0 | 486 | | endif |
| | 487 | |
|
| 0 | 488 | | if(ParamIsDefault(tol)) |
| 0 | 489 | | tol = DEFAULT_TOLERANCE_INT |
| 0 | 490 | | endif |
| | 491 | |
|
| 0 | 492 | | result = IUTF_Checks#IsUINT64Small(var, tol) |
| 0 | 493 | | sprintf str, "%d ~ 0 with tol %g", var, tol |
| 0 | 494 | | EvaluateResults(result, str, flags) |
| 0 | 495 | | End |
| | 496 | |
|
| | 497 | | /// @cond HIDDEN_SYMBOL |
| | 498 | | #endif |
| | 499 | | /// @endcond |
| | 500 | |
|
| | 501 | | /// @class EQUAL_STR_DOCU |
| | 502 | | /// Compares two strings for byte-wise equality. (no encoding considered, no unicode normalization). |
| | 503 | | /// |
| | 504 | | /// This doesn't check if one of the two string are null. If this function is called with a null |
| | 505 | | /// string this will throw a check assertion error. The same will happen if you call this function |
| | 506 | | /// and there is a pending code 185 runtime error. |
| | 507 | | /// |
| | 508 | | /// @param str1 first string |
| | 509 | | /// @param str2 second string |
| | 510 | | /// @param case_sensitive (optional) should the comparison be done case sensitive (1) or case insensitive (1, the defaul |
| 160 | 511 | | static Function EQUAL_STR_WRAPPER(str1, str2, flags, [case_sensitive]) |
| | 512 | | string &str1, &str2 |
| | 513 | | variable case_sensitive |
| | 514 | | variable flags |
| | 515 | |
|
| 160 | 516 | | variable result |
| 160 | 517 | | string str, tmpStr1, tmpStr2 |
| 160 | 518 | | STRUCT IUTF_StringDiffResult diffResult |
| | 519 | |
|
| 160 | 520 | | IUTF_Reporting#incrAssert() |
| | 521 | |
|
| 160 | 522 | | if(shouldDoAbort()) |
| 0 | 523 | | return NaN |
| 160 | 524 | | endif |
| | 525 | |
|
| 160 | 526 | | if(ParamIsDefault(case_sensitive)) |
| 160 | 527 | | case_sensitive = 1 |
| 160 | 528 | | endif |
| | 529 | |
|
| 160 | 530 | | if(GetRTError(0) == RTE_NULL_STRING) |
| 0 | 531 | | IUTF_Basics#ClearRTError() |
| 0 | 532 | | str = "Null string error: One of the provided arguments could be an unsupported null string." |
| 0 | 533 | | EvaluateResults(0, str, CHECK_MODE) |
| 0 | 534 | | IUTF_Reporting#CleanupInfoMsg() |
| 0 | 535 | | return NaN |
| 160 | 536 | | endif |
| | 537 | |
|
| 160 | 538 | | result = IUTF_Checks#AreStringsEqual(str1, str2, case_sensitive) |
| 160 | 539 | | if(!result) |
| 0 | 540 | | IUTF_Utils#DiffString(str1, str2, diffResult, case_sensitive = case_sensitive) |
| 0 | 541 | | sprintf str, "String mismatch (case %ssensitive):\rstr1: %s\rstr2: %s\r", SelectString(case_sensitive, "in", ""), di |
| 0 | 542 | | EvaluateResults(result, str, flags) |
| 160 | 543 | | endif |
| | 544 | |
|
| 160 | 545 | | IUTF_Reporting#CleanupInfoMsg() |
| 160 | 546 | | End |
| | 547 | |
|
| | 548 | | /// @class WAVE_DOCU |
| | 549 | | /// Tests a wave for existence and its type |
| | 550 | | /// |
| | 551 | | /// @param wv wave reference |
| | 552 | | /// @param majorType major wave type |
| | 553 | | /// @param minorType (optional) minor wave type |
| | 554 | | /// |
| | 555 | | /// @verbatim embed:rst:leading-slashes |
| | 556 | | /// See also :ref:`flags_testwave`. |
| | 557 | | /// @endverbatim |
| | 558 | | /// |
| 0 | 559 | | static Function TEST_WAVE_WRAPPER(wv, majorType, flags, [minorType]) |
| | 560 | | WAVE/Z wv |
| | 561 | | variable majorType, minorType |
| | 562 | | variable flags |
| | 563 | |
|
| 0 | 564 | | variable result, type |
| 0 | 565 | | string str, str1, str2 |
| | 566 | |
|
| 0 | 567 | | IUTF_Reporting#incrAssert() |
| | 568 | |
|
| 0 | 569 | | if(shouldDoAbort()) |
| 0 | 570 | | return NaN |
| 0 | 571 | | endif |
| | 572 | |
|
| 0 | 573 | | if(!(majorType & (NULL_WAVE | NUMERIC_WAVE | TEXT_WAVE | DATAFOLDER_WAVE | WAVE_WAVE | NORMAL_WAVE | FREE_WAVE))) |
| 0 | 574 | | EvaluateResults(0, "Valid major type check", flags) |
| 0 | 575 | | return NaN |
| 0 | 576 | | elseif(!ParamIsDefault(minorType) && !(minorType & (NULL_WAVE | NON_NUMERIC_WAVE | COMPLEX_WAVE | FLOAT_WAVE | DOUBLE_ |
| 0 | 577 | | EvaluateResults(0, "Valid minor type check", flags) |
| 0 | 578 | | return NaN |
| 0 | 579 | | endif |
| | 580 | |
|
| 0 | 581 | | result = IUTF_Checks#HasWaveMajorType(wv, majorType) |
| 0 | 582 | | type = IUTF_Checks#GetWaveMajorType(wv) |
| 0 | 583 | | str1 = IUTF_Checks#GetWaveMajorTypeString(majorType) |
| 0 | 584 | | str2 = IUTF_Checks#GetWaveMajorTypeString(type) |
| 0 | 585 | | sprintf str, "Expect wave's main type to be '%s' but got '%s'", str1, str2 |
| 0 | 586 | | EvaluateResults(result, str, flags, cleanupInfo = 0) |
| | 587 | |
|
| 0 | 588 | | if(!ParamIsDefault(minorType)) |
| 0 | 589 | | result = IUTF_Checks#HasWaveMinorType(wv, minorType) |
| 0 | 590 | | type = IUTF_Checks#GetWaveMinorType(wv) |
| 0 | 591 | | str1 = IUTF_Checks#GetWaveMinorTypeString(minorType) |
| 0 | 592 | | str2 = IUTF_Checks#GetWaveMinorTypeString(type) |
| 0 | 593 | | sprintf str, "Expect wave's sub type to be '%s' but got '%s'", str1, str2 |
| 0 | 594 | | EvaluateResults(result, str, flags, cleanupInfo = 0) |
| 0 | 595 | | endif |
| | 596 | |
|
| 0 | 597 | | IUTF_Reporting#CleanupInfoMsg() |
| 0 | 598 | | End |
| | 599 | |
|
| | 600 | | /// @class EQUAL_VAR_DOCU |
| | 601 | | /// Tests two variables for equality. |
| | 602 | | /// |
| | 603 | | /// For variables holding floating point values it is often more desirable use |
| | 604 | | /// CHECK_CLOSE_VAR instead. To fullfill semantic correctness this assertion |
| | 605 | | /// treats two variables with both holding NaN as equal. |
| | 606 | | /// |
| | 607 | | /// @param var1 first variable |
| | 608 | | /// @param var2 second variable |
| 330 | 609 | | static Function EQUAL_VAR_WRAPPER(var1, var2, flags) |
| | 610 | | variable var1, var2 |
| | 611 | | variable flags |
| | 612 | |
|
| 330 | 613 | | variable result |
| 330 | 614 | | string str, tmpStr1, tmpStr2 |
| | 615 | |
|
| 330 | 616 | | IUTF_Reporting#incrAssert() |
| | 617 | |
|
| 330 | 618 | | if(shouldDoAbort()) |
| 0 | 619 | | return NaN |
| 330 | 620 | | endif |
| | 621 | |
|
| 330 | 622 | | result = IUTF_Checks#AreVariablesEqual(var1, var2) |
| 330 | 623 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var1, isDouble = 1) |
| 330 | 624 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(var2, isDouble = 1) |
| 330 | 625 | | sprintf str, "%s == %s", tmpStr1, tmpStr2 |
| 330 | 626 | | EvaluateResults(result, str, flags) |
| 330 | 627 | | End |
| | 628 | |
|
| | 629 | | /// @cond HIDDEN_SYMBOL |
| | 630 | | #if IgorVersion() >= 7.00 |
| | 631 | | /// @endcond |
| | 632 | |
|
| | 633 | | /// @class EQUAL_INT64_DOCU |
| | 634 | | /// Tests two int64 for equality. |
| | 635 | | /// |
| | 636 | | /// @param var1 first variable |
| | 637 | | /// @param var2 second variable |
| 0 | 638 | | static Function EQUAL_INT64_WRAPPER(int64 var1, int64 var2, variable flags) |
| 0 | 639 | | variable result |
| 0 | 640 | | string str |
| | 641 | |
|
| 0 | 642 | | IUTF_Reporting#incrAssert() |
| | 643 | |
|
| 0 | 644 | | if(shouldDoAbort()) |
| 0 | 645 | | return NaN |
| 0 | 646 | | endif |
| | 647 | |
|
| 0 | 648 | | result = IUTF_Checks#AreInt64Equal(var1, var2) |
| 0 | 649 | | sprintf str, "%d == %d", var1, var2 |
| 0 | 650 | | EvaluateResults(result, str, flags) |
| 0 | 651 | | End |
| | 652 | |
|
| | 653 | | /// @class EQUAL_UINT64_DOCU |
| | 654 | | /// Tests two uint64 for equality. |
| | 655 | | /// |
| | 656 | | /// @param var1 first variable |
| | 657 | | /// @param var2 second variable |
| 0 | 658 | | static Function EQUAL_UINT64_WRAPPER(uint64 var1, uint64 var2, variable flags) |
| 0 | 659 | | variable result |
| 0 | 660 | | string str |
| | 661 | |
|
| 0 | 662 | | IUTF_Reporting#incrAssert() |
| | 663 | |
|
| 0 | 664 | | if(shouldDoAbort()) |
| 0 | 665 | | return NaN |
| 0 | 666 | | endif |
| | 667 | |
|
| 0 | 668 | | result = IUTF_Checks#AreUInt64Equal(var1, var2) |
| 0 | 669 | | sprintf str, "%u == %u", var1, var2 |
| 0 | 670 | | EvaluateResults(result, str, flags) |
| 0 | 671 | | End |
| | 672 | |
|
| | 673 | | /// @class NEQ_INT64_DOCU |
| | 674 | | /// Tests two int64 for unequality. |
| | 675 | | /// |
| | 676 | | /// @param var1 first variable |
| | 677 | | /// @param var2 second variable |
| 0 | 678 | | static Function NEQ_INT64_WRAPPER(int64 var1, int64 var2, variable flags) |
| 0 | 679 | | variable result |
| 0 | 680 | | string str |
| | 681 | |
|
| 0 | 682 | | IUTF_Reporting#incrAssert() |
| | 683 | |
|
| 0 | 684 | | if(shouldDoAbort()) |
| 0 | 685 | | return NaN |
| 0 | 686 | | endif |
| | 687 | |
|
| 0 | 688 | | result = !IUTF_Checks#AreInt64Equal(var1, var2) |
| 0 | 689 | | sprintf str, "%d == %d", var1, var2 |
| 0 | 690 | | EvaluateResults(result, str, flags) |
| 0 | 691 | | End |
| | 692 | |
|
| | 693 | | /// @class NEQ_UINT64_DOCU |
| | 694 | | /// Tests two uint64 for unequality. |
| | 695 | | /// |
| | 696 | | /// @param var1 first variable |
| | 697 | | /// @param var2 second variable |
| 0 | 698 | | static Function NEQ_UINT64_WRAPPER(uint64 var1, uint64 var2, variable flags) |
| 0 | 699 | | variable result |
| 0 | 700 | | string str |
| | 701 | |
|
| 0 | 702 | | IUTF_Reporting#incrAssert() |
| | 703 | |
|
| 0 | 704 | | if(shouldDoAbort()) |
| 0 | 705 | | return NaN |
| 0 | 706 | | endif |
| | 707 | |
|
| 0 | 708 | | result = !IUTF_Checks#AreUInt64Equal(var1, var2) |
| 0 | 709 | | sprintf str, "%u == %u", var1, var2 |
| 0 | 710 | | EvaluateResults(result, str, flags) |
| 0 | 711 | | End |
| | 712 | |
|
| | 713 | | /// @cond HIDDEN_SYMBOL |
| | 714 | | #endif |
| | 715 | | /// @endcond |
| | 716 | |
|
| | 717 | | /// @class EQUAL_WAVE_DOCU |
| | 718 | | /// Tests two waves for equality. |
| | 719 | | /// If one wave has a zero size and the other one does not then properties like DIMENSION_UNITS are compared to unequal |
| | 720 | | /// non-existing dimension is always unequal to a property of an existing dimension. |
| | 721 | | /// This function won't throw an assert if both waves have the same reference, because they are considered as equal. |
| | 722 | | /// |
| | 723 | | /// @param wv1 first wave |
| | 724 | | /// @param wv2 second wave |
| | 725 | | /// @param mode (optional) features of the waves to compare, defaults to all modes |
| | 726 | | /// @param tol (optional) tolerance for comparison, by default 0.0 which does byte-by-byte comparison (relevant only |
| | 727 | | /// |
| | 728 | | /// @verbatim embed:rst:leading-slashes |
| | 729 | | /// See also :ref:`flags_equalwave`. |
| | 730 | | /// @endverbatim |
| | 731 | | /// |
| 0 | 732 | | static Function EQUAL_WAVE_WRAPPER(wv1, wv2, flags, [mode, tol]) |
| | 733 | | WAVE/Z wv1, wv2 |
| | 734 | | variable flags |
| | 735 | | variable mode, tol |
| | 736 | |
|
| 0 | 737 | | variable i, result |
| 0 | 738 | | string detailedMsg, name1, name2 |
| 0 | 739 | | string str = "" |
| | 740 | |
|
| 0 | 741 | | IUTF_Reporting#incrAssert() |
| | 742 | |
|
| 0 | 743 | | if(shouldDoAbort()) |
| 0 | 744 | | return NaN |
| 0 | 745 | | endif |
| | 746 | |
|
| 0 | 747 | | result = WaveExists(wv1) |
| | 748 | |
|
| 0 | 749 | | if(!result) |
| 0 | 750 | | EvaluateResults(0, "Assumption that the first wave (wv1) exists", flags) |
| 0 | 751 | | return NaN |
| 0 | 752 | | endif |
| | 753 | |
|
| 0 | 754 | | result = WaveExists(wv2) |
| | 755 | |
|
| 0 | 756 | | if(!result) |
| 0 | 757 | | EvaluateResults(0, "Assumption that the second wave (wv2) exists", flags) |
| 0 | 758 | | return NaN |
| 0 | 759 | | endif |
| | 760 | |
|
| 0 | 761 | | Make/FREE validModes = {WAVE_DATA, WAVE_DATA_TYPE, WAVE_SCALING, DATA_UNITS, DIMENSION_UNITS, DIMENSION_LABELS, WAVE_N |
| | 762 | |
|
| 0 | 763 | | if(ParamIsDefault(mode)) |
| 0 | 764 | | WAVE modes = validModes |
| 0 | 765 | | else |
| 0 | 766 | | if(!IUTF_Utils#IsFinite(mode)) |
| 0 | 767 | | EvaluateResults(0, "Valid mode for EQUAL_WAVE check.", flags) |
| 0 | 768 | | return NaN |
| 0 | 769 | | elseif(!(mode & (WAVE_DATA | WAVE_DATA_TYPE | WAVE_SCALING | DATA_UNITS | DIMENSION_UNITS | DIMENSION_LABELS | WAVE_ |
| 0 | 770 | | EvaluateResults(0, "Valid mode for EQUAL_WAVE check.", flags) |
| 0 | 771 | | return NaN |
| 0 | 772 | | endif |
| | 773 | |
|
| 0 | 774 | | // mode can be a bit pattern, split into separate entities for better debugging |
| 0 | 775 | | Duplicate/FREE validModes, modes |
| | 776 | |
|
| 0 | 777 | | modes[] = (validModes[p] == (validModes[p] & mode)) ? validModes[p] : NaN |
| 0 | 778 | | WaveTransform/O zapNaNs, modes |
| | 779 | |
|
| 0 | 780 | | if(!DimSize(modes, 0)) |
| 0 | 781 | | EvaluateResults(0, "Valid mode for EQUAL_WAVE check.", flags) |
| 0 | 782 | | return NaN |
| 0 | 783 | | endif |
| 0 | 784 | | endif |
| | 785 | |
|
| 0 | 786 | | if(ParamIsDefault(tol)) |
| 0 | 787 | | tol = 0.0 |
| 0 | 788 | | elseif(IUTF_Utils#IsNaN(tol)) |
| 0 | 789 | | EvaluateResults(0, "Valid tolerance for EQUAL_WAVE check.", flags) |
| 0 | 790 | | return NaN |
| 0 | 791 | | elseif(tol < 0) |
| 0 | 792 | | EvaluateResults(0, "Valid tolerance for EQUAL_WAVE check.", flags) |
| 0 | 793 | | return NaN |
| 0 | 794 | | endif |
| | 795 | |
|
| 0 | 796 | | for(i = 0; i < DimSize(modes, 0); i += 1) |
| 0 | 797 | | mode = modes[i] |
| 0 | 798 | | result = IUTF_Checks#AreWavesEqual(wv1, wv2, mode, tol, detailedMsg) |
| | 799 | |
|
| 0 | 800 | | if(!result) |
| 0 | 801 | | name1 = IUTF_Utils#GetWaveNameInDFStr(wv1) |
| 0 | 802 | | name2 = IUTF_Utils#GetWaveNameInDFStr(wv2) |
| 0 | 803 | | sprintf str, "Assuming equality using mode %s for waves %s and %s", EqualWavesModeToString(mode), name1, name2 |
| | 804 | |
|
| 0 | 805 | | if(!IUTF_Utils#IsEmpty(detailedMsg)) |
| 0 | 806 | | str += "; detailed: " + detailedMsg |
| 0 | 807 | | endif |
| 0 | 808 | | endif |
| | 809 | |
|
| 0 | 810 | | EvaluateResults(result, str, flags, cleanupInfo = 0) |
| 0 | 811 | | endfor |
| | 812 | |
|
| 0 | 813 | | IUTF_Reporting#CleanupInfoMsg() |
| 0 | 814 | | End |
| | 815 | |
|
| | 816 | | /// @class LESS_EQUAL_VAR_DOCU |
| | 817 | | /// Tests that var1 is less or equal than var2 |
| | 818 | | /// |
| | 819 | | /// @param var1 first variable |
| | 820 | | /// @param var2 second variable |
| 0 | 821 | | static Function LESS_EQUAL_VAR_WRAPPER(var1, var2, flags) |
| | 822 | | variable var1, var2, flags |
| | 823 | |
|
| 0 | 824 | | variable result |
| 0 | 825 | | string str, tmpStr1, tmpStr2 |
| | 826 | |
|
| 0 | 827 | | IUTF_Reporting#incrAssert() |
| | 828 | |
|
| 0 | 829 | | if(shouldDoAbort()) |
| 0 | 830 | | return NaN |
| 0 | 831 | | endif |
| | 832 | |
|
| 0 | 833 | | result = IUTF_Checks#IsLessOrEqual(var1, var2) |
| 0 | 834 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var1, isDouble = 1) |
| 0 | 835 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(var2, isDouble = 1) |
| 0 | 836 | | sprintf str, "%s <= %s", tmpStr1, tmpStr2 |
| 0 | 837 | | EvaluateResults(result, str, flags) |
| 0 | 838 | | End |
| | 839 | |
|
| | 840 | | /// @class LESS_THAN_VAR_DOCU |
| | 841 | | /// Tests that var1 is less than var2 |
| | 842 | | /// |
| | 843 | | /// @param var1 first variable |
| | 844 | | /// @param var2 second variable |
| 0 | 845 | | static Function LESS_THAN_VAR_WRAPPER(var1, var2, flags) |
| | 846 | | variable var1, var2, flags |
| | 847 | |
|
| 0 | 848 | | variable result |
| 0 | 849 | | string str, tmpStr1, tmpStr2 |
| | 850 | |
|
| 0 | 851 | | IUTF_Reporting#incrAssert() |
| | 852 | |
|
| 0 | 853 | | if(shouldDoAbort()) |
| 0 | 854 | | return NaN |
| 0 | 855 | | endif |
| | 856 | |
|
| 0 | 857 | | result = IUTF_Checks#IsLess(var1, var2) |
| 0 | 858 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var1, isDouble = 1) |
| 0 | 859 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(var2, isDouble = 1) |
| 0 | 860 | | sprintf str, "%s < %s", tmpStr1, tmpStr2 |
| 0 | 861 | | EvaluateResults(result, str, flags) |
| 0 | 862 | | End |
| | 863 | |
|
| | 864 | | /// @class GREATER_EQUAL_VAR_DOCU |
| | 865 | | /// Tests that var1 is greather or equal than var2 |
| | 866 | | /// |
| | 867 | | /// @param var1 first variable |
| | 868 | | /// @param var2 second variable |
| 0 | 869 | | static Function GREATER_EQUAL_VAR_WRAPPER(var1, var2, flags) |
| | 870 | | variable var1, var2, flags |
| | 871 | |
|
| 0 | 872 | | variable result |
| 0 | 873 | | string str, tmpStr1, tmpStr2 |
| | 874 | |
|
| 0 | 875 | | IUTF_Reporting#incrAssert() |
| | 876 | |
|
| 0 | 877 | | if(shouldDoAbort()) |
| 0 | 878 | | return NaN |
| 0 | 879 | | endif |
| | 880 | |
|
| 0 | 881 | | result = IUTF_Checks#IsLessOrEqual(var2, var1) |
| 0 | 882 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var1, isDouble = 1) |
| 0 | 883 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(var2, isDouble = 1) |
| 0 | 884 | | sprintf str, "%s >= %s", tmpStr1, tmpStr2 |
| 0 | 885 | | EvaluateResults(result, str, flags) |
| 0 | 886 | | End |
| | 887 | |
|
| | 888 | | /// @class GREATER_THAN_VAR_DOCU |
| | 889 | | /// Tests that var1 is greather than var2 |
| | 890 | | /// |
| | 891 | | /// @param var1 first variable |
| | 892 | | /// @param var2 second variable |
| 0 | 893 | | static Function GREATER_THAN_VAR_WRAPPER(var1, var2, flags) |
| | 894 | | variable var1, var2, flags |
| | 895 | |
|
| 0 | 896 | | variable result |
| 0 | 897 | | string str, tmpStr1, tmpStr2 |
| | 898 | |
|
| 0 | 899 | | IUTF_Reporting#incrAssert() |
| | 900 | |
|
| 0 | 901 | | if(shouldDoAbort()) |
| 0 | 902 | | return NaN |
| 0 | 903 | | endif |
| | 904 | |
|
| 0 | 905 | | result = IUTF_Checks#IsLess(var2, var1) |
| 0 | 906 | | tmpStr1 = IUTF_Utils#GetNiceStringForNumber(var1, isDouble = 1) |
| 0 | 907 | | tmpStr2 = IUTF_Utils#GetNiceStringForNumber(var2, isDouble = 1) |
| 0 | 908 | | sprintf str, "%s > %s", tmpStr1, tmpStr2 |
| 0 | 909 | | EvaluateResults(result, str, flags) |
| 0 | 910 | | End |
| | 911 | |
|
| 0 | 912 | | static Function/S RTE2String(code, [msg]) |
| | 913 | | variable code |
| | 914 | | string msg |
| | 915 | |
|
| 0 | 916 | | string result |
| | 917 | |
|
| 0 | 918 | | if(code) |
| 0 | 919 | | if(ParamIsDefault(msg)) |
| 0 | 920 | | sprintf result, "RTE %d", code |
| 0 | 921 | | else |
| 0 | 922 | | sprintf result, "RTE %d \"%s\"", code, msg |
| 0 | 923 | | endif |
| 0 | 924 | | return result |
| 0 | 925 | | else |
| 0 | 926 | | return "no RTE" |
| 0 | 927 | | endif |
| 0 | 928 | | End |
| | 929 | |
|
| | 930 | | /// @class RTE_DOCU |
| | 931 | | /// Tests if a RTE with the specified code was thrown. This assertion will clear any pending RTEs. |
| | 932 | | /// |
| | 933 | | /// Hint: You have to add INFO() statements before the statement that is tested. INFO() won't do |
| | 934 | | /// something if a pending RTE exists. |
| | 935 | | /// |
| | 936 | | /// @param code the code that is expected to be thrown |
| 0 | 937 | | static Function RTE_WRAPPER(code, flags) |
| | 938 | | variable code, flags |
| | 939 | |
|
| 0 | 940 | | variable result, err |
| 0 | 941 | | string str, msg |
| | 942 | |
|
| 0 | 943 | | IUTF_Reporting#incrAssert() |
| | 944 | |
|
| 0 | 945 | | if(shouldDoAbort()) |
| 0 | 946 | | return NaN |
| 0 | 947 | | endif |
| | 948 | |
|
| 0 | 949 | | result = IUTF_Checks#HasRTE(code) |
| 0 | 950 | | msg = GetRTErrMessage() |
| 0 | 951 | | err = GetRTError(1) |
| | 952 | |
|
| 0 | 953 | | sprintf str, "Expecting %s but got %s", RTE2String(code), RTE2String(err, msg = msg) |
| 0 | 954 | | EvaluateResults(result, str, flags) |
| 0 | 955 | | End |
| | 956 | |
|
| | 957 | | /// @class ANY_RTE_DOCU |
| | 958 | | /// Tests if any RTE was thrown. This assertion will clear any pending RTEs. |
| | 959 | | /// |
| | 960 | | /// Hint: You have to add INFO() statements before the statement that is tested. INFO() won't do |
| | 961 | | /// something if a pending RTE exists. |
| 0 | 962 | | static Function ANY_RTE_WRAPPER(flags) |
| | 963 | | variable flags |
| | 964 | |
|
| 0 | 965 | | variable result, err |
| 0 | 966 | | string str |
| | 967 | |
|
| 0 | 968 | | IUTF_Reporting#incrAssert() |
| | 969 | |
|
| 0 | 970 | | if(shouldDoAbort()) |
| 0 | 971 | | return NaN |
| 0 | 972 | | endif |
| | 973 | |
|
| 0 | 974 | | result = IUTF_Checks#HasAnyRTE() |
| 0 | 975 | | err = GetRTError(1) |
| | 976 | |
|
| 0 | 977 | | sprintf str, "Expecting any RTE but got nothing" |
| 0 | 978 | | EvaluateResults(result, str, flags) |
| 0 | 979 | | End |
| | 980 | |
|
| | 981 | | /// @class NO_RTE_DOCU |
| | 982 | | /// Tests if no RTEs are thrown. This assertion will clear any pending RTEs. |
| | 983 | | /// |
| | 984 | | /// Hint: You have to add INFO() statements before the statement that is tested. INFO() won't do |
| | 985 | | /// something if a pending RTE exists. |
| 0 | 986 | | static Function NO_RTE_WRAPPER(flags) |
| | 987 | | variable flags |
| | 988 | |
|
| 0 | 989 | | RTE_WRAPPER(0, flags) |
| 0 | 990 | | End |
| | 991 | |
|
| | 992 | | /// @class COMPILATION_DOCU |
| | 993 | | /// Tests if the specified Igor Pro file can be compiled with the list of defines. This assertion |
| | 994 | | /// can only be used if IUTF is located inside an independent module. This assertion needs to be the |
| | 995 | | /// last assertion of the current test case. If you want to continue your test case after this |
| | 996 | | /// assertion try to split your test case into multiple functions and specify the next part in the |
| | 997 | | /// optional parameter reentry. |
| | 998 | | /// |
| | 999 | | /// It is recommended to start Igor with the <tt>/CompErrNoDialog</tt> (alternatively |
| | 1000 | | /// <tt>/UNATTENDED</tt> since Igor 9) command line argument to prevent error pop-ups when a single |
| | 1001 | | /// compilation failed. |
| | 1002 | | /// |
| | 1003 | | /// @param file The Igor Pro procedure file that should be tested. This must be a valid path |
| | 1004 | | /// that can be used in the <tt>\#include "file"</tt> syntax. |
| | 1005 | | /// @param defines (optional) A text wave which contains globally defined flags that are |
| | 1006 | | /// used for conditional compilation. If this parameter is not set it will be |
| | 1007 | | /// treated as if an empty wave was provided and won't set any flags. |
| | 1008 | | /// @param reentry (optional) The full function name of the reentry function that will be executed |
| | 1009 | | /// after this assertion finished. If this parameter is not used the test case will |
| | 1010 | | // be finished after this assertion. |
| 4 | 1011 | | static Function COMPILATION_WRAPPER(file, flags, [defines, reentry, noCompile]) |
| | 1012 | | string file |
| | 1013 | | variable flags |
| | 1014 | | WAVE/Z/T defines |
| | 1015 | | string reentry |
| | 1016 | | variable noCompile |
| | 1017 | |
|
| 4 | 1018 | | variable tmpVar |
| | 1019 | |
|
| 4 | 1020 | | noCompile = ParamIsDefault(noCompile) ? 0 : !!noCompile |
| | 1021 | |
|
| 4 | 1022 | | IUTF_Reporting#incrAssert() |
| | 1023 | |
|
| 4 | 1024 | | if(shouldDoAbort()) |
| 0 | 1025 | | return NaN |
| 4 | 1026 | | endif |
| | 1027 | |
|
| 4 | 1028 | | if(!CmpStr(GetIndependentModuleName(), "ProcGlobal")) |
| 0 | 1029 | | IUTF_Reporting#ReportErrorAndAbort("This assertion is only allowed to be called in an independent module") |
| 4 | 1030 | | endif |
| | 1031 | |
|
| 4 | 1032 | | if(!ParamIsDefault(reentry)) |
| 1 | 1033 | | if(IUTF_Utils#IsEmpty(reentry)) |
| 0 | 1034 | | IUTF_Reporting#ReportErrorAndAbort("Reentry parameter is an empty string") |
| 1 | 1035 | | endif |
| | 1036 | |
|
| 1 | 1037 | | if(GrepString(reentry, PROCNAME_NOT_REENTRY)) |
| 0 | 1038 | | IUTF_Reporting#ReportErrorAndAbort("Name of Reentry function must end with _REENTRY") |
| 1 | 1039 | | endif |
| 1 | 1040 | | FUNCREF TEST_CASE_PROTO rFuncRef = $reentry |
| 1 | 1041 | | FUNCREF TEST_CASE_PROTO_MD rFuncRefMMD = $reentry |
| 1 | 1042 | | if(!IUTF_FuncRefIsAssigned(FuncRefInfo(rFuncRef)) && !IUTF_FuncRefIsAssigned(FuncRefInfo(rFuncRefMMD)) && !IUTF_Test |
| 0 | 1043 | | IUTF_Reporting#ReportErrorAndAbort("Specified reentry procedure has wrong format. The format must be function_REEN |
| 1 | 1044 | | endif |
| 3 | 1045 | | else |
| 3 | 1046 | | reentry = "" |
| 4 | 1047 | | endif |
| | 1048 | |
|
| 4 | 1049 | | if(ParamIsDefault(defines) || !WaveExists(defines)) |
| 3 | 1050 | | Make/FREE/N=0/T defines |
| 4 | 1051 | | endif |
| | 1052 | |
|
| 4 | 1053 | | IUTF_Test_Compilation#TestCompilation(file, flags, defines, reentry, noCompile) |
| 4 | 1054 | | End |
| | 1055 | |
|
| | 1056 | | /// @class NO_COMPILATION_DOCU |
| | 1057 | | /// Tests if the specified Igor Pro file cannot be compiled with the list of defines. This assertion |
| | 1058 | | /// can only be used if IUTF is located inside an independent module. This assertion needs to be the |
| | 1059 | | /// last assertion of the current test case. If you want to continue your test case after this |
| | 1060 | | /// assertion try to split your test case into multiple functions and specify the next part in the |
| | 1061 | | /// optional parameter reentry. |
| | 1062 | | /// |
| | 1063 | | /// It is recommended to start Igor with the <tt>/CompErrNoDialog</tt> (alternatively |
| | 1064 | | /// <tt>/UNATTENDED</tt> since Igor 9) command line argument to prevent error pop-ups when a single |
| | 1065 | | /// compilation failed. |
| | 1066 | | /// |
| | 1067 | | /// @param file The Igor Pro procedure file that should be tested. This must be a valid path |
| | 1068 | | /// that can be used in the <tt>\#include "file"</tt> syntax. |
| | 1069 | | /// @param defines (optional) A text wave which contains globally defined flags that are |
| | 1070 | | /// used for conditional compilation. If this parameter is not set it will be |
| | 1071 | | /// treated as if an empty wave was provided and won't set any flags. |
| | 1072 | | /// @param reentry (optional) The full function name of the reentry function that will be executed |
| | 1073 | | /// after this assertion finished. If this parameter is not used the test case will |
| | 1074 | | // be finished after this assertion. |
| 2 | 1075 | | static Function NO_COMPILATION_WRAPPER(file, flags, [defines, reentry]) |
| | 1076 | | string file |
| | 1077 | | variable flags |
| | 1078 | | WAVE/Z/T defines |
| | 1079 | | string reentry |
| | 1080 | |
|
| 2 | 1081 | | if(ParamIsDefault(defines)) |
| 2 | 1082 | | if(ParamIsDefault(reentry)) |
| 1 | 1083 | | COMPILATION_WRAPPER(file, flags, noCompile = 1) |
| 1 | 1084 | | else |
| 1 | 1085 | | COMPILATION_WRAPPER(file, flags, reentry = reentry, noCompile = 1) |
| 2 | 1086 | | endif |
| 0 | 1087 | | else |
| 0 | 1088 | | if(ParamIsDefault(reentry)) |
| 0 | 1089 | | COMPILATION_WRAPPER(file, flags, defines = defines, noCompile = 1) |
| 0 | 1090 | | else |
| 0 | 1091 | | COMPILATION_WRAPPER(file, flags, defines = defines, reentry = reentry, noCompile = 1) |
| 0 | 1092 | | endif |
| 2 | 1093 | | endif |
| 2 | 1094 | | End |