wiki:Projects/GSoC/TestSuite/framework_design

Version 7 (modified by Xiaochen Pan, on Aug 23, 2012 at 7:25:54 AM) (diff)

/* Integer */

TestSuite/framework design

Validity Test

assert_true(condition);

assert_true(condition, message);

assert_false(condition);

assert_false(condition, message)

assert_fail();

assert_fail(message);

Numerical Tests

Integer

assert_int_equal(expected, actual);

assert_int_not_equal(expected, actual)

assert_int_lt(expected, actual);

assert actual less than expected

assert_int_le(expected, actual);

assert actual less than or equal to expected

assert_int_gt(expected, actual);

assert actual greater than expected

assert_int_ge(expected, actual);

assert actual greater than or equal to expected

assert_int8_equal(expected, actual);

8 bit integers comparison and display errors as signed integer

assert_int8_not_equal(expected, actual);

assert_uint8_equal(expected, actual);

8 bit integers comparison and display errors as unsigned integer

assert_uint8_not_equal(expected, actual);

assert_int16_equal(expected, actual);

16 bit integers comparison and display errors as signed integer

assert_int16_not_equal(expected, actual);

assert_uint16_equal(expected, actual);

16 bit integers comparison and display errors as unsigned integer

assert_uint16_not_equal(expected, actual);

assert_int32_equal(expected, actual);

32 bit integers comparison and display errors as signed integer

assert_int32_not_equal(expected, actual);

assert_uint32_equal(expected, actual);

32 bit integers comparison and display errors as unsigned integer

assert_uint32_not_equal(expected, actual);

assert_int64_equal(expected, actual);

64 bit integers comparison and display errors as signed integer

assert_int64_not_equal(expected, actual);

assert_uint64_equal(expected, actual);

64 bit integers comparison and display errors as unsigned integer

assert_uint64_not_equal(expected, actual);

assert_int_within(delta, expected, actual);

assert_uint_within(delta, expected, actual);

test integer is within plus or minus of another integer and display error as unsigned integer

assert_bits(mask, expected, actual);

Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored.

assert_bits_high(mask, actual);

Use an integer mask to specify which bits should be inspected to determine if they are all set high.

assert_bits_low(mask, actual);

Use an integer mask to specify which bits should be inspected to determine if they are all set high.

assert_bit_high(bit, actual);

Test a single bit and verify that it is high.

assert_bit_low(bit, actual);

Test a single bit and verify that it is low

Floats

assert_float_equal(expected, actual)

assert_float_not_equal(expected, actual)

assert_float_within(delta, expected, actual)

assert_float_lt(expected, actual)

Asserts that the actual value is less than expected within a couple of significant bits

assert_float_le(expected, actual)

assert_float_gt(expected, actual)

assert_float_ge(expected, actual)

assert_double_equal(expected, actual)

assert_double_not_equal(expected, actual)

assert_double_within(delta, expected, actual)

assert_double_lt(expected, actual)

Asserts that the actual value is less than expected within a couple of significant bits

assert_double_le(expected, actual)

assert_double_gt(expected, actual)

assert_double_ge(expected, actual)

String

assert_string_equal(expected, actual, message)

assert_string_not_equal(expected, actual, message)

Pointer Tests

assert_pointer_null(pointer);

assert_pointer_not_null(pointer):

assert_pointer_equal(expected, actual);

Memory Tests

assert_memory_equal(expected, actual, len);

Run Test Macro

RUN_TEST(func, linenum)

Each Test is run within the macro RUN_TEST. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards. Just pass it the name of the test function to run and the line number the test function starts on (for default error reporting). If you have some special needs, you can override RUN_TEST by defining it to be your own macro before including Unity.h

Death Test Macro

TEST_PROTECT();

TEST_ABOART();

Example:

main() {

if (TEST_PROTECT() == 0) {

MyTest?();

}

}

If MyTest? calls TEST_ABORT, program control will immediately return to TEST_PROTECT with a non-zero return value.

Ignore Test

TEST_IGNORE()

TEST_IGNORE_MESSAGE()