Cheat Sheet

Overview

The reference manual will give you all the available functions and their usage. This is a cheat sheet for a quick lookup.

Asserts

ASSERT_FAIL(m, ...)     /* Force a failure with printf style message */
ASSERT_TRUE(x)          /* Assert the condition is true */
ASSERT_FALSE(x)         /* Assert the condition is false */
ASSERT_NULL(x)          /* Assert the value is null */
ASSERT_NOT_NULL(x)      /* Assert the value is not null */
ASSERT_EQ(x, y)         /* Assert the integer values are equal */
ASSERT_NEQ(x, y)        /* Assert the integer values are not equal */
ASSERT_FP_EQ(x, y, d)   /* Assert the float values are within delta 'd' */
ASSERT_FP_NEQ(x, y, d)  /* Assert the float values are not within delta 'd' */
ASSERT_STR_EQ(x, y)     /* Assert the string values compare the same */
ASSERT_STR_NEQ(x, y)    /* Assert the string values are different */

Setup

SETUP(f, v)             /* Setup a mock to return a value */
SETUP_COUNT(f, v, n)    /* Setup a mock to return a value on nth call */
SETUP_ALWAYS(f, v)      /* Setup a mock to always return the same value */
SETUP_FP(f, v)          /* Setup a mock to return a floating point value */
SETUP_FP_COUNT(f, v, n) /* Setup a mock to return a fp value on nth call */
SETUP_FP_ALWAYS(f, v)   /* Setup a mock to always return the same fp value */

Verify

VERIFY_VOID(f)           /* Verify a function was called */
VERIFY(f, p, v)          /* Verify a funct param was called with a value */
VERIFY_NEVER(f, n, v)    /* Verify a func param was not called with a value */
VERIFY_SEQ(f, n, s, v)      /* Verify a function param called in sequence */
VERIFY_NOT_SEQ(f, n, s, v)  /* Verify a func param not called in sequence */
VERIFY_STR(f, p, v)             /* String (char *) parameter versions ... */
VERIFY_STR_NEVER(f, n, v)
VERIFY_STR_SEQ(f, n, s, v)
VERIFY_STR_NOT_SEQ(f, n, s, v)
VERIFY_FP(f, p, v, d)            /* Floating point parameter versions ... */
VERIFY_FP_NEVER(f, n, v, d)      /* Require a delta for comparisons to work */
VERIFY_FP_SEQ(f, n, s, v, d)
VERIFY_FP_NOT_SEQ(f, n, s, v, d)

Record

RECORD(n)           /* In parameter body, record a parameter called */
RECORD_STR(n)       /* Record a string parameter called */
RECORD_FP(n)        /* Record a floating point parameter called */
RECORD_VOID()       /* Record a function called with no parameters */

Replay

REPLAY()        /* In a mock return a previously setup value */
REPLAY_FP()     /* In a mock return a previously setup floating point value */

Expect

EXPECT(s)        /* Expect the given signal */