## Assertions Assertions — Checks that your program works as you expect. |

## Synopsis

    #define             cut_error                           (format, ...)
    #define             cut_fail                            (format, ...)
    #define             cut_pend                            (format, ...)
    #define             cut_pending                         (format, ...)
    #define             cut_notify                          (format, ...)
    #define             cut_omit                            (format, ...)
    #define             cut_assert                          (expression, ...)
    #define             cut_assert_true                     (expression, ...)
    #define             cut_assert_false                    (expression, ...)
    #define             cut_assert_null                     (expression, ...)
    #define             cut_assert_null_string              (expression, ...)
    #define             cut_assert_not_null                 (expression, ...)
    #define             cut_assert_equal_int                (expected, actual, ...)
    #define             cut_assert_equal_uint               (expected, actual, ...)
    #define             cut_assert_equal_double             (expected, error, actual, ...)
    #define             cut_assert_equal_string             (expected, actual, ...)
    #define             cut_assert_equal_string_with_free   (expected, actual, ...)
    #define             cut_assert_equal_string_or_null     (expected, actual, ...)
    #define             cut_assert_equal_memory             (expected, expected_size,
                                                             actual, actual_size, ...)
    #define             cut_assert_equal_string_array       (expected, actual, ...)
    #define             cut_assert_equal_string_array_with_free(expected, actual, ...)
    #define             cut_assert_operator                 (lhs, operator, rhs, ...)
    #define             cut_assert_operator_int             (lhs, operator, rhs, ...)
    #define             cut_assert_equal                    (function, expected, actual, ...)
    #define             cut_assert_errno                    (...)
    #define             cut_assert_file_exist               (path, ...)
    #define             cut_assert_match                    (pattern, actual, ...)
    #define             cut_assert_match_with_free          (pattern, actual, ...)
    #define             cut_assert_equal_pointer            (expected, actual, ...)

## Description

To check that your program works as you expect, you use `cut_assert_XXX()` where you want to check expected value is got.

e.g.:

    cut_assert_equal_int(3, 1 + 2);

## Details

### cut_error()

    #define             cut_error(format, ...)

Raises an error with message.

`format` : | the message format. See the `printf()` documentation.
`...` : | the parameters to insert into the format string.

### cut_fail()

    #define             cut_fail(format, ...)

Raises a failure with message.

`format` : | the message format. See the `printf()` documentation.
`...` : | the parameters to insert into the format string.

### cut_pend()

    #define             cut_pend(format, ...)

Marks the test is pending with message. The test is stopped.

`format` : | the message format. See the `printf()` documentation.
`...` : | the parameters to insert into the format string.

### cut_pending()

    #define cut_pending(format, ...) cut_pend(format, ## __VA_ARGS__)

### Warning

`cut_pending` has been deprecated since version 0.4 and should not be used in newly-written code. Use `cut_pend()` instead.

Marks the test is pending with message. The test is stopped.

`format` : | the message format. See the `printf()` documentation.
`...` : | the parameters to insert into the format string.

### cut_notify()

    #define             cut_notify(format, ...)

Leaves a notification message. The test is continued.

`format` : | the message format. See the `printf()` documentation.
`...` : | the parameters to insert into the format string.

### cut_omit()

    #define             cut_omit(format, ...)

Omit the test.

e.g.:

    if (version < 2.0)
      cut_omit("Require >= 2.0");

`format` : | the message format. See the `printf()` documentation.
`...` : | the parameters to insert into the format string.

Since 0.8

### cut_assert()

    #define             cut_assert(expression, ...)

Passes if `expression` is not 0 or NULL.

`expression` : | the expression to check.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_true()

    #define             cut_assert_true(expression, ...)

Passes if `expression` is TRUE value (not 0 or NULL).

`expression` : | the expression to check.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 0.9

### cut_assert_false()

    #define             cut_assert_false(expression, ...)

Passes if `expression` is 0 or NULL.

`expression` : | the expression to check.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 0.9

### cut_assert_null()

    #define             cut_assert_null(expression, ...)

Passes if `expression` is NULL.

`expression` : | the expression to check.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_null_string()

    #define             cut_assert_null_string(expression, ...)

Passes if `expression` is NULL.

`expression` : | the expression that returns string.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 0.3

### cut_assert_not_null()

    #define             cut_assert_not_null(expression, ...)

Passes if `expression` is not NULL.

`expression` : | the expression to check.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_int()

    #define             cut_assert_equal_int(expected, actual, ...)

Passes if `expected` == `actual`.

`expected` : | an expected integer value.
`actual` : | an actual integer value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_uint()

    #define             cut_assert_equal_uint(expected, actual, ...)

Passes if `expected` == `actual`.

`expected` : | an expected unsigned integer value.
`actual` : | an actual unsigned integer value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_double()

    #define             cut_assert_equal_double(expected, error, actual, ...)

Passes if (`expected` - `error`) <= `actual` <= (`expected` + `error`).

`expected` : | an expected float value.
`error` : | an float value that specifies error range.
`actual` : | an actual float value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_string()

    #define             cut_assert_equal_string(expected, actual, ...)

Passes if both `expected` and `actual` are NULL or strcmp(`expected`, `actual`) == 0.

`expected` : | an expected string value.
`actual` : | an actual string value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_string_with_free()

    #define             cut_assert_equal_string_with_free(expected, actual, ...)

Passes if both `expected` and `actual` are NULL or strcmp(`expected`, `actual`) == 0.

`expected` : | an expected string value.
`actual` : | an actual string value that is freed.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 0.3

### cut_assert_equal_string_or_null()

    #define             cut_assert_equal_string_or_null(expected, actual, ...)

### Warning

`cut_assert_equal_string_or_null` has been deprecated since version 0.3 and should not be used in newly-written code. Use `cut_assert_equal_string()` instead.

Passes if both `expected` and `actual` are NULL or strcmp(`expected`, `actual`) == 0.

`expected` : | an expected string value.
`actual` : | an actual string value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_memory()

    #define             cut_assert_equal_memory(expected, expected_size,                \
                                                actual, actual_size, ...)

Passes if `expected_size` == `actual_size` and memcmp(`expected`, `actual`, `expected_size`) == 0.

`expected` : | an expected data.
`expected_size` : | a size of `expected`.
`actual` : | an actual data.
`actual_size` : | a size of `actual`.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_string_array()

    #define             cut_assert_equal_string_array(expected, actual, ...)

Passes if both `expected` and `actual` are not NULL and have same content (`strcmp()` == 0) strings.

`expected` : | an expected NULL-terminated array of strings.
`actual` : | an actual NULL-terminated array of strings that are freed.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal_string_array_with_free()

    #define             cut_assert_equal_string_array_with_free(expected, actual, ...)

Passes if both `expected` and `actual` are not NULL and have same content (`strcmp()` == 0) strings.

`expected` : | an expected NULL-terminated array of strings.
`actual` : | an actual NULL-terminated array of strings.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 0.9

### cut_assert_operator()

    #define             cut_assert_operator(lhs, operator, rhs, ...)

Passes if (`lhs` `operator` `rhs`) is TRUE.

e.g.:

    cut_assert_operator(1, <, 2) -> (1 < 2);

`lhs` : | a left hand side value.
`operator` : | a binary operator.
`rhs` : | a right hand side value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_operator_int()

    #define             cut_assert_operator_int(lhs, operator, rhs, ...)

Passes if (`lhs` `operator` `rhs`) is TRUE.

e.g.:

    cut_assert_operator_int(1, <, 2) -> (1 < 2);

`lhs` : | a left hand side integer value.
`operator` : | a binary operator.
`rhs` : | a right hand side integer value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_equal()

    #define             cut_assert_equal(function, expected, actual, ...)

Passes if `function`(`expected`, `actual`) returns TRUE.

e.g.:

    cut_assert_equal(!strcmp, "abc", "abc"); -> Pass

`function` : | a function that compares `actual` with `expected`.
`expected` : | an expected value.
`actual` : | an actual value.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

### cut_assert_errno()

    #define             cut_assert_errno(...)

Passes if errno is 0.

e.g.:

    count = write(stdout, buffer, strlen(buffer));
    cut_assert_errno("Failed to write");            -> Pass when count != -1

`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 0.8

### cut_assert_file_exist()

    #define             cut_assert_file_exist(path, ...)

Passes if `path` is exist. It may or may not be a regular file.

e.g.:

    cut_assert_file_exist("/tmp");             -> Pass on many environment.
    cut_assert_file_exist("/non-existent");    -> Fail

`path` : | the path to test.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 0.9

### cut_assert_match()

    #define             cut_assert_match(pattern, actual, ...)

Passes if `regex` matches `string`.

e.g.:

    cut_assert_match("^abc", "abc");            -> Pass
    cut_assert_match("^abc", " abc");           -> Fail

`pattern` : | the regular expression as string.
`actual` : | the string to be matched.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 1.0

### cut_assert_match_with_free()

    #define             cut_assert_match_with_free(pattern, actual, ...)

Passes if `regex` matches `string`. See `cut_assert_match()` for detail.

`pattern` : | the regular expression as string.
`actual` : | the string to be matched that is freed.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 1.0

### cut_assert_equal_pointer()

    #define             cut_assert_equal_pointer(expected, actual, ...)

Passes if `expected` == `actual`.

`expected` : | an expected pointer.
`actual` : | an actual pointer.
`...` : | optional format string, followed by parameters to insert into the format string (as with `printf()`)

Since 1.0