Assertions¶
-
variable CHECK(variable var)¶
Tests if var is non-zero and not “Not a Number” (NaN).
- Parameters:
var – variable to test
-
variable CHECK_ANY_RTE()¶
Tests if any RTE was thrown. This assertion will clear any pending RTEs.
Hint: You have to add INFO() statements before the statement that is tested. INFO() won’t do something if a pending RTE exists.
-
variable CHECK_CLOSE_CMPLX(variable/c var1, variable/c var2, variable tol = defaultValue, variable strong = defaultValue)¶
Compares two variables and determines if they are close.
Based on the implementation of “Floating-point comparison algorithms” in the C++ Boost unit testing framework.
Literature:
The art of computer programming (Vol II). Donald. E. Knuth. 0-201-89684-2. Addison-Wesley Professional; 3 edition, page 234 equation (34) and (35).
Variant for complex numbers.
- Parameters:
var1 – first variable
var2 – second variable
tol – (optional) tolerance, defaults to 1e-8
strong – (optional) type of condition, can be 0 for weak or 1 for strong (default)
-
variable CHECK_CLOSE_INT64(int64 var1, int64 var2, int64 tol = defaultValue)¶
Compares two int64 and determines if they are close.
- Parameters:
var1 – first int64 variable
var2 – second int64 variable
tol – (optional) int64 tolerance, defaults to 16
-
variable CHECK_CLOSE_UINT64(uint64 var1, uint64 var2, uint64 tol = defaultValue)¶
Compares two uint64 and determines if they are close.
- Parameters:
var1 – first uint64 variable
var2 – second uint64 variable
tol – (optional) uint64 tolerance, defaults to 16
-
variable CHECK_CLOSE_VAR(variable var1, variable var2, variable tol = defaultValue, variable strong = defaultValue)¶
Compares two variables and determines if they are close.
Based on the implementation of “Floating-point comparison algorithms” in the C++ Boost unit testing framework.
Literature:
The art of computer programming (Vol II). Donald. E. Knuth. 0-201-89684-2. Addison-Wesley Professional; 3 edition, page 234 equation (34) and (35).
- Parameters:
var1 – first variable
var2 – second variable
tol – (optional) tolerance, defaults to 1e-8
strong – (optional) type of condition, can be 0 for weak or 1 for strong (default)
-
variable CHECK_COMPILATION(string file, WaveTextOrNull defines = defaultValue, string reentry = defaultValue)¶
Tests if the specified Igor Pro file can be compiled with the list of defines. This assertion can only be used if IUTF is located inside an independent module. This assertion needs to be the last assertion of the current test case. If you want to continue your test case after this assertion try to split your test case into multiple functions and specify the next part in the optional parameter reentry.
It is recommended to start Igor with the
/CompErrNoDialog
(alternatively/UNATTENDED
since Igor 9) command line argument to prevent error pop-ups when a single compilation failed.- Parameters:
file – The Igor Pro procedure file that should be tested. This must be a valid path that can be used in the
#include "file"
syntax.defines – (optional) A text wave which contains globally defined flags that are used for conditional compilation. If this parameter is not set it will be treated as if an empty wave was provided and won’t set any flags.
reentry – (optional) The full function name of the reentry function that will be executed after this assertion finished. If this parameter is not used the test case will
-
variable CHECK_EMPTY_FOLDER()¶
Tests if the current data folder is empty.
Counted are objects with type waves, strings, variables and folders
-
variable CHECK_EMPTY_STR(string *str)¶
Tests if str is empty.
A null string is never empty.
- Parameters:
str – string to test
-
variable CHECK_EQUAL_INT64(int64 var1, int64 var2)¶
Tests two int64 for equality.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_EQUAL_STR(string str1, string str2, variable case_sensitive = defaultValue)¶
Compares two strings for byte-wise equality. (no encoding considered, no unicode normalization).
This doesn’t check if one of the two string are null. If this function is called with a null string this will throw a check assertion error. The same will happen if you call this function and there is a pending code 185 runtime error.
- Parameters:
str1 – first string
str2 – second string
case_sensitive – (optional) should the comparison be done case sensitive (1) or case insensitive (1, the default)
-
variable CHECK_EQUAL_TEXTWAVES(WaveText wv1, WaveText wv2, variable mode = defaultValue)¶
Tests two text waves for equality.
See also Test Wave Flags.
- Parameters:
wv1 – first text wave, can be invalid for Igor Pro 7 or later
wv2 – second text wave, can be invalid for Igor Pro 7 or later
mode – (optional) features of the waves to compare, defaults to all modes
-
variable CHECK_EQUAL_UINT64(uint64 var1, uint64 var2)¶
Tests two uint64 for equality.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_EQUAL_VAR(variable var1, variable var2)¶
Tests two variables for equality.
For variables holding floating point values it is often more desirable use CHECK_CLOSE_VAR instead. To fullfill semantic correctness this assertion treats two variables with both holding NaN as equal.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_EQUAL_WAVES(WaveOrNull wv1, WaveOrNull wv2, variable mode = defaultValue, variable tol = defaultValue)¶
Tests two waves for equality. If one wave has a zero size and the other one does not then properties like DIMENSION_UNITS are compared to unequal as a property for a non-existing dimension is always unequal to a property of an existing dimension. This function won’t throw an assert if both waves have the same reference, because they are considered as equal.
See also Equal Wave Flags.
- Parameters:
wv1 – first wave
wv2 – second wave
mode – (optional) features of the waves to compare, defaults to all modes
tol – (optional) tolerance for comparison, by default 0.0 which does byte-by-byte comparison (relevant only for mode=WAVE_DATA)
-
variable CHECK_GE_VAR(variable var1, variable var2)¶
Tests that var1 is greather or equal than var2.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_GT_VAR(variable var1, variable var2)¶
Tests that var1 is greather than var2.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_LE_VAR(variable var1, variable var2)¶
Tests that var1 is less or equal than var2.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_LT_VAR(variable var1, variable var2)¶
Tests that var1 is less than var2.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_NEQ_INT64(int64 var1, int64 var2)¶
Tests two int64 for unequality.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_NEQ_STR(string str1, string str2, variable case_sensitive = defaultValue)¶
Compares two strings for unequality.
This doesn’t check if one of the two string are null. If this function is called with a null string this will throw a check assertion error. The same will happen if you call this function and there is a pending code 185 runtime error.
- Parameters:
str1 – first string
str2 – second string
case_sensitive – (optional) should the comparison be done case sensitive (1) or case insensitive (0, the default)
-
variable CHECK_NEQ_UINT64(uint64 var1, uint64 var2)¶
Tests two uint64 for unequality.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_NEQ_VAR(variable var1, variable var2)¶
Tests two variables for inequality.
- Parameters:
var1 – first variable
var2 – second variable
-
variable CHECK_NO_COMPILATION(string file, WaveTextOrNull defines = defaultValue, string reentry = defaultValue)¶
Tests if the specified Igor Pro file cannot be compiled with the list of defines. This assertion can only be used if IUTF is located inside an independent module. This assertion needs to be the last assertion of the current test case. If you want to continue your test case after this assertion try to split your test case into multiple functions and specify the next part in the optional parameter reentry.
It is recommended to start Igor with the
/CompErrNoDialog
(alternatively/UNATTENDED
since Igor 9) command line argument to prevent error pop-ups when a single compilation failed.- Parameters:
file – The Igor Pro procedure file that should be tested. This must be a valid path that can be used in the
#include "file"
syntax.defines – (optional) A text wave which contains globally defined flags that are used for conditional compilation. If this parameter is not set it will be treated as if an empty wave was provided and won’t set any flags.
reentry – (optional) The full function name of the reentry function that will be executed after this assertion finished. If this parameter is not used the test case will
-
variable CHECK_NO_RTE()¶
Tests if no RTEs are thrown. This assertion will clear any pending RTEs.
Hint: You have to add INFO() statements before the statement that is tested. INFO() won’t do something if a pending RTE exists.
-
variable CHECK_NON_EMPTY_STR(string *str)¶
Tests if str is not empty.
A null string is a non empty string too.
- Parameters:
str – string to test
-
variable CHECK_NON_NULL_STR(string *str)¶
Tests if str is not null.
An empty string is always non null.
- Parameters:
str – string to test
-
variable CHECK_NULL_STR(string *str)¶
Tests if str is null.
An empty string is never null.
- Parameters:
str – string to test
-
variable CHECK_PROPER_STR(string *str)¶
Tests if str is a “proper” string, i.e. a string with a length larger than zero.
Neither null strings nor empty strings are proper strings.
- Parameters:
str – string to test
-
variable CHECK_RTE(variable code)¶
Tests if a RTE with the specified code was thrown. This assertion will clear any pending RTEs.
Hint: You have to add INFO() statements before the statement that is tested. INFO() won’t do something if a pending RTE exists.
- Parameters:
code – the code that is expected to be thrown
-
variable CHECK_SMALL_CMPLX(variable/c var, variable tol = defaultValue)¶
Tests if a variable is small using the inequality \( | var | < | tol | \).
Variant for complex numbers
- Parameters:
var – variable
tol – (optional) tolerance, defaults to 1e-8
-
variable CHECK_SMALL_INT64(int64 var, int64 tol = defaultValue)¶
Tests if a int64 variable is small using the inequality \( | var | < | tol | \).
- Parameters:
var – int64 variable
tol – (optional) int64 tolerance, defaults to 16
-
variable CHECK_SMALL_UINT64(uint64 var, uint64 tol = defaultValue)¶
Tests if a uint64 variable is small using the inequality \( var < tol \).
- Parameters:
var – uint64 variable
tol – (optional) uint64 tolerance, defaults to 16
-
variable CHECK_SMALL_VAR(variable var, variable tol = defaultValue)¶
Tests if a variable is small using the inequality \( | var | < | tol | \).
- Parameters:
var – variable
tol – (optional) tolerance, defaults to 1e-8
-
variable CHECK_WAVE(WaveOrNull wv, variable majorType, variable minorType = defaultValue)¶
Tests a wave for existence and its type.
See also Test Wave Flags.
- Parameters:
wv – wave reference
majorType – major wave type
minorType – (optional) minor wave type
-
variable FAIL()¶
Force the test case to fail.
-
variable INFO(string format, WaveText s = defaultValue, wave n = defaultValue, string s0 = defaultValue, string s1 = defaultValue, string s2 = defaultValue, string s3 = defaultValue, string s4 = defaultValue, variable n0 = defaultValue, variable n1 = defaultValue, variable n2 = defaultValue, variable n3 = defaultValue, variable n4 = defaultValue)¶
Append information to the next assertion to print if failed.
-
variable PASS()¶
Increase the assertion counter only.
-
variable REQUIRE(variable var)¶
Tests if var is non-zero and not “Not a Number” (NaN).
- Parameters:
var – variable to test
-
variable REQUIRE_ANY_RTE()¶
Tests if any RTE was thrown. This assertion will clear any pending RTEs.
Hint: You have to add INFO() statements before the statement that is tested. INFO() won’t do something if a pending RTE exists.
- variable REQUIRE_CLOSE_CMPLX(variable/c var1