|
CCCC
C bytecode compiler + VM interpreter
|
CCCC Test Framework — assertion API injected in –testing mode. More...
Go to the source code of this file.
Macros | |
| #define | Assert(cond) __builtin_assert(!!(cond), #cond, __FILE__, __LINE__) |
| Assert that a condition is true. | |
| #define | AssertTrue(cond) Assert(cond) |
| Assert that a condition is true (alias for Assert). | |
| #define | AssertFalse(cond) __builtin_assert_false(!!(cond), #cond, __FILE__, __LINE__) |
| Assert that a condition is false. | |
| #define | AssertFail() __builtin_assert_fail(__FILE__, __LINE__) |
| Unconditionally fail the current test. | |
| #define | AssertFailMsg(msg) __builtin_assert_fail_msg(msg, __FILE__, __LINE__) |
| Unconditionally fail the current test with a custom message. | |
| #define | AssertEq(a, b) |
| Assert two integers are equal. | |
| #define | AssertNeq(a, b) |
| Assert two integers are not equal. | |
| #define | AssertGt(a, b) |
| Assert one integer is greater than another. | |
| #define | AssertLt(a, b) |
| Assert one integer is less than another. | |
| #define | AssertGe(a, b) |
| Assert one integer is greater than or equal to another. | |
| #define | AssertLe(a, b) |
| Assert one integer is less than or equal to another. | |
| #define | AssertWithin(delta, expected, actual) |
| Assert an integer is within a delta of an expected value. | |
| #define | AssertBits(mask, expected, actual) |
| Assert that specific bits match between expected and actual values. | |
| #define | AssertBitHigh(bit, actual) |
| Assert that a specific bit is set (high/1). | |
| #define | AssertBitLow(bit, actual) |
| Assert that a specific bit is clear (low/0). | |
| #define | AssertFloatWithin(delta, expected, actual) |
| Assert a float is within a delta of an expected value. | |
| #define | AssertDoubleWithin(delta, expected, actual) |
| Assert a double is within a delta of an expected value. | |
| #define | AssertFloatEq(expected, actual) |
| Assert two floats are approximately equal (default epsilon 1e-6). | |
| #define | AssertDoubleEq(expected, actual) |
| Assert two doubles are approximately equal (default epsilon 1e-15). | |
| #define | AssertNull(p) __builtin_assert_null((const void *)(p), #p, __FILE__, __LINE__) |
| Assert a pointer is NULL. | |
| #define | AssertNotNull(p) __builtin_assert_not_null((const void *)(p), #p, __FILE__, __LINE__) |
| Assert a pointer is not NULL. | |
| #define | AssertStrEq(a, b) __builtin_assert_streq((a), (b), #a, #b, __FILE__, __LINE__) |
| Assert two C strings are equal. | |
| #define | AssertStrEqLen(a, b, len) |
| Assert two C strings are equal up to a given length. | |
| #define | AssertMemEq(expected, actual, len) |
| Assert two memory regions are byte-identical. | |
| #define | AssertArrayEq(expected, actual, count) |
| Assert two arrays are element-by-element equal. | |
| #define | AssertEachEq(expected, actual, count) |
| Assert each element of an array equals a scalar expected value. | |
| #define | AssertMsg(cond, msg) __builtin_assert_msg(!!(cond), #cond, msg, __FILE__, __LINE__) |
| Assert a condition is true with a custom message. | |
| #define | AssertTrueMsg(cond, msg) AssertMsg(cond, msg) |
| Assert a condition is true with a custom message (alias for AssertMsg). | |
| #define | AssertFalseMsg(cond, msg) __builtin_assert_msg(!(cond), #cond, msg, __FILE__, __LINE__) |
| Assert a condition is false with a custom message. | |
| #define | AssertEqMsg(a, b, msg) |
| Assert two integers are equal with a custom message. | |
| #define | AssertStrEqMsg(a, b, msg) __builtin_assert_streq_msg((a), (b), #a, #b, msg, __FILE__, __LINE__) |
| Assert two C strings are equal with a custom message. | |
| #define | AssertNullMsg(p, msg) __builtin_assert_null_msg((const void *)(p), #p, msg, __FILE__, __LINE__) |
| Assert a pointer is NULL with a custom message. | |
| #define | AssertNotNullMsg(p, msg) |
| Assert a pointer is not NULL with a custom message. | |
| #define | AssertBitsMsg(mask, expected, actual, msg) |
| Assert specific bits match with a custom message. | |
Functions | |
| void | __builtin_assert (int cond, const char *expr, const char *file, int line) |
| Assert that a condition is true. | |
| void | __builtin_assert_false (int cond, const char *expr, const char *file, int line) |
| Assert that a condition is false. | |
| void | __builtin_assert_fail (const char *file, int line) |
| Unconditionally fail a test. | |
| void | __builtin_assert_fail_msg (const char *msg, const char *file, int line) |
| Unconditionally fail a test with a custom message. | |
| void | __builtin_assert_eq (long long a, long long b, const char *as, const char *bs, const char *file, int line) |
| Assert that two integers are equal. | |
| void | __builtin_assert_neq (long long a, long long b, const char *as, const char *bs, const char *file, int line) |
| Assert that two integers are not equal. | |
| void | __builtin_assert_gt (long long a, long long b, const char *as, const char *bs, const char *file, int line) |
| Assert that one integer is greater than another. | |
| void | __builtin_assert_lt (long long a, long long b, const char *as, const char *bs, const char *file, int line) |
| Assert that one integer is less than another. | |
| void | __builtin_assert_ge (long long a, long long b, const char *as, const char *bs, const char *file, int line) |
| Assert that one integer is greater than or equal to another. | |
| void | __builtin_assert_le (long long a, long long b, const char *as, const char *bs, const char *file, int line) |
| Assert that one integer is less than or equal to another. | |
| void | __builtin_assert_within (long long delta, long long expected, long long actual, const char *ds, const char *es, const char *as, const char *file, int line) |
| Assert that an integer is within a delta of an expected value. | |
| void | __builtin_assert_null (const void *p, const char *ps, const char *file, int line) |
| Assert that a pointer is NULL. | |
| void | __builtin_assert_not_null (const void *p, const char *ps, const char *file, int line) |
| Assert that a pointer is not NULL. | |
| void | __builtin_assert_streq (const char *a, const char *b, const char *as, const char *bs, const char *file, int line) |
| Assert that two C strings are equal (full strcmp). | |
| void | __builtin_assert_streq_len (const char *a, const char *b, long long len, const char *as, const char *bs, const char *file, int line) |
| Assert that two C strings are equal up to a given length. | |
| void | __builtin_assert_mem_eq (const void *expected, const void *actual, long long len, const char *es, const char *as, const char *file, int line) |
| Assert that two memory regions are byte-identical. | |
| void | __builtin_assert_float_within (double delta, double expected, double actual, const char *ds, const char *es, const char *as, const char *file, int line) |
| Assert that a float is within a delta of an expected value. | |
| void | __builtin_assert_double_within (double delta, double expected, double actual, const char *ds, const char *es, const char *as, const char *file, int line) |
| Assert that a double is within a delta of an expected value. | |
| void | __builtin_assert_bits (long long mask, long long expected, long long actual, const char *ms, const char *es, const char *as, const char *file, int line) |
| Assert that specific bits match between expected and actual values. | |
| void | __builtin_assert_bit_high (int bit, long long actual, const char *bs, const char *as, const char *file, int line) |
| Assert that a specific bit is set (high/1). | |
| void | __builtin_assert_bit_low (int bit, long long actual, const char *bs, const char *as, const char *file, int line) |
| Assert that a specific bit is clear (low/0). | |
| void | __builtin_assert_eq_array (const void *expected, const void *actual, long long elem_size, long long count, const char *es, const char *as, const char *file, int line) |
| Assert that two arrays are element-by-element equal. | |
| void | __builtin_assert_msg (int cond, const char *expr, const char *msg, const char *file, int line) |
| Assert a condition is true with a custom message. | |
| void | __builtin_assert_eq_msg (long long a, long long b, const char *as, const char *bs, const char *msg, const char *file, int line) |
| Assert two integers are equal with a custom message. | |
| void | __builtin_assert_streq_msg (const char *a, const char *b, const char *as, const char *bs, const char *msg, const char *file, int line) |
| Assert two C strings are equal with a custom message. | |
| void | __builtin_assert_null_msg (const void *p, const char *ps, const char *msg, const char *file, int line) |
| Assert a pointer is NULL with a custom message. | |
| void | __builtin_assert_not_null_msg (const void *p, const char *ps, const char *msg, const char *file, int line) |
| Assert a pointer is not NULL with a custom message. | |
| void | __builtin_assert_bits_msg (long long mask, long long expected, long long actual, const char *ms, const char *es, const char *as, const char *msg, const char *file, int line) |
| Assert specific bits match with a custom message. | |
CCCC Test Framework — assertion API injected in –testing mode.
This header provides macros and underlying FFI-callable builtins for writing self-verifying test programs. It is automatically injected when CCCC is invoked with the --testing flag and should not be included directly.
A test passes if it exits with code 42.
Each assertion macro expands to a call to an FFI-callable __builtin_assert_* function. On failure, the builtin prints the source location and expression, then terminates with a failure exit code.
| #define Assert | ( | cond | ) | __builtin_assert(!!(cond), #cond, __FILE__, __LINE__) |
Assert that a condition is true.
| cond | The condition to test. |
Expands to __builtin_assert with stringified expression, source file, and line. Equivalent to AssertTrue.
| #define AssertArrayEq | ( | expected, | |
| actual, | |||
| count | |||
| ) |
Assert two arrays are element-by-element equal.
| expected | Pointer to expected array. |
| actual | Pointer to actual array. |
| count | Number of elements (element size is inferred). |
Uses sizeof((expected)[0]) to infer element size.
| #define AssertBitHigh | ( | bit, | |
| actual | |||
| ) |
Assert that a specific bit is set (high/1).
| bit | Zero-based bit index. |
| actual | Value to inspect. |
Passes if (actual >> bit) & 1.
| #define AssertBitLow | ( | bit, | |
| actual | |||
| ) |
Assert that a specific bit is clear (low/0).
| bit | Zero-based bit index. |
| actual | Value to inspect. |
Passes if !((actual >> bit) & 1).
| #define AssertBits | ( | mask, | |
| expected, | |||
| actual | |||
| ) |
Assert that specific bits match between expected and actual values.
| mask | Bit mask to apply. |
| expected | Expected masked value. |
| actual | Actual value to mask and compare. |
Passes if (actual & mask) == (expected & mask).
| #define AssertBitsMsg | ( | mask, | |
| expected, | |||
| actual, | |||
| msg | |||
| ) |
Assert specific bits match with a custom message.
| mask | Bit mask to apply. |
| expected | Expected masked value. |
| actual | Actual value to mask and compare. |
| msg | Custom failure message. |
| #define AssertDoubleEq | ( | expected, | |
| actual | |||
| ) |
Assert two doubles are approximately equal (default epsilon 1e-15).
| expected | Expected value. |
| actual | Actual value. |
Uses a default delta of 1e-15.
| #define AssertDoubleWithin | ( | delta, | |
| expected, | |||
| actual | |||
| ) |
Assert a double is within a delta of an expected value.
| delta | Maximum allowed absolute difference. |
| expected | Expected value. |
| actual | Actual value. |
| #define AssertEachEq | ( | expected, | |
| actual, | |||
| count | |||
| ) |
Assert each element of an array equals a scalar expected value.
| expected | Scalar expected value. |
| actual | Array expression. |
| count | Number of elements. |
Iterates over the array and compares each element individually. On failure, reports the failing index as "[i]".
| #define AssertEq | ( | a, | |
| b | |||
| ) |
Assert two integers are equal.
| a | Left-hand operand. |
| b | Right-hand operand. |
| #define AssertEqMsg | ( | a, | |
| b, | |||
| msg | |||
| ) |
Assert two integers are equal with a custom message.
| a | Left-hand operand. |
| b | Right-hand operand. |
| msg | Custom failure message. |
| #define AssertFail | ( | ) | __builtin_assert_fail(__FILE__, __LINE__) |
Unconditionally fail the current test.
| #define AssertFailMsg | ( | msg | ) | __builtin_assert_fail_msg(msg, __FILE__, __LINE__) |
Unconditionally fail the current test with a custom message.
| msg | Custom failure message. |
| #define AssertFalse | ( | cond | ) | __builtin_assert_false(!!(cond), #cond, __FILE__, __LINE__) |
Assert that a condition is false.
| cond | The condition to test (must evaluate to zero). |
| #define AssertFalseMsg | ( | cond, | |
| msg | |||
| ) | __builtin_assert_msg(!(cond), #cond, msg, __FILE__, __LINE__) |
Assert a condition is false with a custom message.
| cond | The condition to test. |
| msg | Custom failure message. |
| #define AssertFloatEq | ( | expected, | |
| actual | |||
| ) |
Assert two floats are approximately equal (default epsilon 1e-6).
| expected | Expected value. |
| actual | Actual value. |
Uses a default delta of 1e-6.
| #define AssertFloatWithin | ( | delta, | |
| expected, | |||
| actual | |||
| ) |
Assert a float is within a delta of an expected value.
| delta | Maximum allowed absolute difference. |
| expected | Expected value. |
| actual | Actual value. |
| #define AssertGe | ( | a, | |
| b | |||
| ) |
Assert one integer is greater than or equal to another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| #define AssertGt | ( | a, | |
| b | |||
| ) |
Assert one integer is greater than another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| #define AssertLe | ( | a, | |
| b | |||
| ) |
Assert one integer is less than or equal to another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| #define AssertLt | ( | a, | |
| b | |||
| ) |
Assert one integer is less than another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| #define AssertMemEq | ( | expected, | |
| actual, | |||
| len | |||
| ) |
Assert two memory regions are byte-identical.
| expected | Pointer to expected data. |
| actual | Pointer to actual data. |
| len | Number of bytes to compare. |
| #define AssertMsg | ( | cond, | |
| msg | |||
| ) | __builtin_assert_msg(!!(cond), #cond, msg, __FILE__, __LINE__) |
Assert a condition is true with a custom message.
| cond | The condition to test. |
| msg | Custom failure message. |
| #define AssertNeq | ( | a, | |
| b | |||
| ) |
Assert two integers are not equal.
| a | Left-hand operand. |
| b | Right-hand operand. |
| #define AssertNotNull | ( | p | ) | __builtin_assert_not_null((const void *)(p), #p, __FILE__, __LINE__) |
Assert a pointer is not NULL.
| p | The pointer to check. |
| #define AssertNotNullMsg | ( | p, | |
| msg | |||
| ) |
Assert a pointer is not NULL with a custom message.
| p | The pointer to check. |
| msg | Custom failure message. |
| #define AssertNull | ( | p | ) | __builtin_assert_null((const void *)(p), #p, __FILE__, __LINE__) |
Assert a pointer is NULL.
| p | The pointer to check. |
| #define AssertNullMsg | ( | p, | |
| msg | |||
| ) | __builtin_assert_null_msg((const void *)(p), #p, msg, __FILE__, __LINE__) |
Assert a pointer is NULL with a custom message.
| p | The pointer to check. |
| msg | Custom failure message. |
| #define AssertStrEq | ( | a, | |
| b | |||
| ) | __builtin_assert_streq((a), (b), #a, #b, __FILE__, __LINE__) |
Assert two C strings are equal.
| a | Expected string. |
| b | Actual string. |
| #define AssertStrEqLen | ( | a, | |
| b, | |||
| len | |||
| ) |
Assert two C strings are equal up to a given length.
| a | Expected string. |
| b | Actual string. |
| len | Maximum number of characters to compare. |
| #define AssertStrEqMsg | ( | a, | |
| b, | |||
| msg | |||
| ) | __builtin_assert_streq_msg((a), (b), #a, #b, msg, __FILE__, __LINE__) |
Assert two C strings are equal with a custom message.
| a | Expected string. |
| b | Actual string. |
| msg | Custom failure message. |
| #define AssertTrue | ( | cond | ) | Assert(cond) |
Assert that a condition is true (alias for Assert).
| cond | The condition to test. |
| #define AssertTrueMsg | ( | cond, | |
| msg | |||
| ) | AssertMsg(cond, msg) |
Assert a condition is true with a custom message (alias for AssertMsg).
| cond | The condition to test. |
| msg | Custom failure message. |
| #define AssertWithin | ( | delta, | |
| expected, | |||
| actual | |||
| ) |
Assert an integer is within a delta of an expected value.
| delta | Maximum allowed absolute difference. |
| expected | Expected value. |
| actual | Actual value. |
Passes if |actual - expected| <= delta.
| void __builtin_assert | ( | int | cond, |
| const char * | expr, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a condition is true.
| cond | The boolean condition (must be non-zero to pass). |
| expr | Stringified expression for diagnostic output. |
| file | Source file name. |
| line | Source line number. |
cond is non-zero; otherwise prints the failure location/expression and terminates the test with a non-zero exit code.Backend for Assert and AssertTrue.
| void __builtin_assert_bit_high | ( | int | bit, |
| long long | actual, | ||
| const char * | bs, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a specific bit is set (high/1).
| bit | Zero-based bit index. |
| actual | Value to inspect. |
| bs | Stringified bit index expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
bit of actual is set; otherwise terminates the test with a non-zero exit code.Backend for AssertBitHigh. Passes if (actual >> bit) & 1.
| void __builtin_assert_bit_low | ( | int | bit, |
| long long | actual, | ||
| const char * | bs, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a specific bit is clear (low/0).
| bit | Zero-based bit index. |
| actual | Value to inspect. |
| bs | Stringified bit index expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
bit of actual is clear; otherwise terminates the test with a non-zero exit code.Backend for AssertBitLow. Passes if !((actual >> bit) & 1).
| void __builtin_assert_bits | ( | long long | mask, |
| long long | expected, | ||
| long long | actual, | ||
| const char * | ms, | ||
| const char * | es, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that specific bits match between expected and actual values.
| mask | Bit mask to apply. |
| expected | Expected masked value. |
| actual | Actual value to mask and compare. |
| ms | Stringified mask expression. |
| es | Stringified expected expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
(actual & mask) == (expected & mask); otherwise prints all three values and terminates the test with a non-zero exit code.Backend for AssertBits. Passes if (actual & mask) == (expected & mask).
| void __builtin_assert_bits_msg | ( | long long | mask, |
| long long | expected, | ||
| long long | actual, | ||
| const char * | ms, | ||
| const char * | es, | ||
| const char * | as, | ||
| const char * | msg, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert specific bits match with a custom message.
| mask | Bit mask to apply. |
| expected | Expected masked value. |
| actual | Actual value to mask and compare. |
| ms | Stringified mask expression. |
| es | Stringified expected expression. |
| as | Stringified actual expression. |
| msg | Custom failure message. |
| file | Source file name. |
| line | Source line number. |
(actual & mask) == (expected & mask); otherwise prints all three values, msg, and terminates the test with a non-zero exit code.Backend for AssertBitsMsg. Passes if (actual & mask) == (expected & mask).
| void __builtin_assert_double_within | ( | double | delta, |
| double | expected, | ||
| double | actual, | ||
| const char * | ds, | ||
| const char * | es, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a double is within a delta of an expected value.
| delta | Maximum allowed absolute difference. |
| expected | Expected value. |
| actual | Actual value. |
| ds | Stringified delta expression. |
| es | Stringified expected expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
|actual - expected| <= delta; otherwise prints all three values and terminates the test with a non-zero exit code.Backend for AssertDoubleWithin and AssertDoubleEq. Passes if |actual - expected| <= delta.
| void __builtin_assert_eq | ( | long long | a, |
| long long | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that two integers are equal.
| a | Left-hand operand. |
| b | Right-hand operand. |
| as | Stringified left expression. |
| bs | Stringified right expression. |
| file | Source file name. |
| line | Source line number. |
a equals b; otherwise prints both values and terminates the test with a non-zero exit code.Backend for AssertEq.
| void __builtin_assert_eq_array | ( | const void * | expected, |
| const void * | actual, | ||
| long long | elem_size, | ||
| long long | count, | ||
| const char * | es, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that two arrays are element-by-element equal.
| expected | Pointer to expected array. |
| actual | Pointer to actual array. |
| elem_size | Size of each element in bytes. |
| count | Number of elements to compare. |
| es | Stringified expected expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
memcmp; otherwise terminates the test with a non-zero exit code.Backend for AssertArrayEq. Uses memcmp internally.
| void __builtin_assert_eq_msg | ( | long long | a, |
| long long | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | msg, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert two integers are equal with a custom message.
| a | Left-hand operand. |
| b | Right-hand operand. |
| as | Stringified left expression. |
| bs | Stringified right expression. |
| msg | Custom failure message. |
| file | Source file name. |
| line | Source line number. |
a equals b; otherwise prints both values, msg, and terminates the test with a non-zero exit code.Backend for AssertEqMsg.
| void __builtin_assert_fail | ( | const char * | file, |
| int | line | ||
| ) |
Unconditionally fail a test.
| file | Source file name. |
| line | Source line number. |
Backend for AssertFail.
| void __builtin_assert_fail_msg | ( | const char * | msg, |
| const char * | file, | ||
| int | line | ||
| ) |
Unconditionally fail a test with a custom message.
| msg | Custom failure message. |
| file | Source file name. |
| line | Source line number. |
msg and the failure location, then terminates the test with a non-zero exit code.Backend for AssertFailMsg.
| void __builtin_assert_false | ( | int | cond, |
| const char * | expr, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a condition is false.
| cond | The boolean condition (must be zero to pass). |
| expr | Stringified expression for diagnostic output. |
| file | Source file name. |
| line | Source line number. |
cond is zero; otherwise prints the failure location/expression and terminates the test with a non-zero exit code.Backend for AssertFalse.
| void __builtin_assert_float_within | ( | double | delta, |
| double | expected, | ||
| double | actual, | ||
| const char * | ds, | ||
| const char * | es, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a float is within a delta of an expected value.
| delta | Maximum allowed absolute difference. |
| expected | Expected value. |
| actual | Actual value. |
| ds | Stringified delta expression. |
| es | Stringified expected expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
|actual - expected| <= delta; otherwise prints all three values and terminates the test with a non-zero exit code.Backend for AssertFloatWithin and AssertFloatEq. Passes if |actual - expected| <= delta.
| void __builtin_assert_ge | ( | long long | a, |
| long long | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that one integer is greater than or equal to another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| as | Stringified left expression. |
| bs | Stringified right expression. |
| file | Source file name. |
| line | Source line number. |
a is greater than or equal to b; otherwise prints both values and terminates the test with a non-zero exit code.Backend for AssertGe.
| void __builtin_assert_gt | ( | long long | a, |
| long long | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that one integer is greater than another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| as | Stringified left expression. |
| bs | Stringified right expression. |
| file | Source file name. |
| line | Source line number. |
a is greater than b; otherwise prints both values and terminates the test with a non-zero exit code.Backend for AssertGt.
| void __builtin_assert_le | ( | long long | a, |
| long long | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that one integer is less than or equal to another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| as | Stringified left expression. |
| bs | Stringified right expression. |
| file | Source file name. |
| line | Source line number. |
a is less than or equal to b; otherwise prints both values and terminates the test with a non-zero exit code.Backend for AssertLe.
| void __builtin_assert_lt | ( | long long | a, |
| long long | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that one integer is less than another.
| a | Left-hand operand. |
| b | Right-hand operand. |
| as | Stringified left expression. |
| bs | Stringified right expression. |
| file | Source file name. |
| line | Source line number. |
a is less than b; otherwise prints both values and terminates the test with a non-zero exit code.Backend for AssertLt.
| void __builtin_assert_mem_eq | ( | const void * | expected, |
| const void * | actual, | ||
| long long | len, | ||
| const char * | es, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that two memory regions are byte-identical.
| expected | Pointer to expected data. |
| actual | Pointer to actual data. |
| len | Number of bytes to compare. |
| es | Stringified expected expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
memcmp; otherwise terminates the test with a non-zero exit code.Backend for AssertMemEq. Uses memcmp for comparison.
| void __builtin_assert_msg | ( | int | cond, |
| const char * | expr, | ||
| const char * | msg, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert a condition is true with a custom message.
| cond | The boolean condition (must be non-zero to pass). |
| expr | Stringified expression for diagnostic output. |
| msg | Custom failure message. |
| file | Source file name. |
| line | Source line number. |
cond is non-zero; otherwise prints msg and the failure location, then terminates the test with a non-zero exit code.Backend for AssertMsg and AssertTrueMsg.
| void __builtin_assert_neq | ( | long long | a, |
| long long | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that two integers are not equal.
| a | Left-hand operand. |
| b | Right-hand operand. |
| as | Stringified left expression. |
| bs | Stringified right expression. |
| file | Source file name. |
| line | Source line number. |
a differs from b; otherwise prints both values and terminates the test with a non-zero exit code.Backend for AssertNeq.
| void __builtin_assert_not_null | ( | const void * | p, |
| const char * | ps, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a pointer is not NULL.
| p | The pointer to check. |
| ps | Stringified pointer expression. |
| file | Source file name. |
| line | Source line number. |
p is non-NULL; otherwise terminates the test with a non-zero exit code.Backend for AssertNotNull.
| void __builtin_assert_not_null_msg | ( | const void * | p, |
| const char * | ps, | ||
| const char * | msg, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert a pointer is not NULL with a custom message.
| p | The pointer to check. |
| ps | Stringified pointer expression. |
| msg | Custom failure message. |
| file | Source file name. |
| line | Source line number. |
p is non-NULL; otherwise prints msg and terminates the test with a non-zero exit code.Backend for AssertNotNullMsg.
| void __builtin_assert_null | ( | const void * | p, |
| const char * | ps, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that a pointer is NULL.
| p | The pointer to check. |
| ps | Stringified pointer expression. |
| file | Source file name. |
| line | Source line number. |
p is NULL; otherwise prints the pointer value and terminates the test with a non-zero exit code.Backend for AssertNull.
| void __builtin_assert_null_msg | ( | const void * | p, |
| const char * | ps, | ||
| const char * | msg, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert a pointer is NULL with a custom message.
| p | The pointer to check. |
| ps | Stringified pointer expression. |
| msg | Custom failure message. |
| file | Source file name. |
| line | Source line number. |
p is NULL; otherwise prints msg and terminates the test with a non-zero exit code.Backend for AssertNullMsg.
| void __builtin_assert_streq | ( | const char * | a, |
| const char * | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that two C strings are equal (full strcmp).
| a | Expected string. |
| b | Actual string. |
| as | Stringified expected expression. |
| bs | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
a and b compare equal via strcmp; otherwise prints both strings and terminates the test with a non-zero exit code.Backend for AssertStrEq. Uses strcmp for comparison.
| void __builtin_assert_streq_len | ( | const char * | a, |
| const char * | b, | ||
| long long | len, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that two C strings are equal up to a given length.
| a | Expected string. |
| b | Actual string. |
| len | Maximum number of characters to compare. |
| as | Stringified expected expression. |
| bs | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
a and b compare equal for the first len characters via strncmp; otherwise prints both strings and terminates the test with a non-zero exit code.Backend for AssertStrEqLen. Uses strncmp for comparison.
| void __builtin_assert_streq_msg | ( | const char * | a, |
| const char * | b, | ||
| const char * | as, | ||
| const char * | bs, | ||
| const char * | msg, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert two C strings are equal with a custom message.
| a | Expected string. |
| b | Actual string. |
| as | Stringified expected expression. |
| bs | Stringified actual expression. |
| msg | Custom failure message. |
| file | Source file name. |
| line | Source line number. |
a and b compare equal via strcmp; otherwise prints both strings, msg, and terminates the test with a non-zero exit code.Backend for AssertStrEqMsg.
| void __builtin_assert_within | ( | long long | delta, |
| long long | expected, | ||
| long long | actual, | ||
| const char * | ds, | ||
| const char * | es, | ||
| const char * | as, | ||
| const char * | file, | ||
| int | line | ||
| ) |
Assert that an integer is within a delta of an expected value.
| delta | Maximum allowed absolute difference. |
| expected | Expected value. |
| actual | Actual value. |
| ds | Stringified delta expression. |
| es | Stringified expected expression. |
| as | Stringified actual expression. |
| file | Source file name. |
| line | Source line number. |
|actual - expected| <= delta; otherwise prints all three values and terminates the test with a non-zero exit code.Backend for AssertWithin. Passes if |actual - expected| <= delta.