FleCSI User API Version: 2.3.0
 
Loading...
Searching...
No Matches
Unit Testing

Unit test framework much like Google Test but with task support. More...

Macros

#define UNIT(...)
 Define a unit test function.
 
#define UNIT_ASSERT(ASSERTION, ...)
 Run an assertion and include captured output in any error message.
 
#define UNIT_CAPTURE()
 A stream that collects output for comparison.
 
#define UNIT_DUMP()
 Return captured output.
 
#define UNIT_EQUAL_BLESSED(f)
 Compare captured output to a blessed file.
 
#define UNIT_WRITE(f)
 Write captured output to file.
 

Typedefs

template<target_type Target>
using driver = action< Target, test_control_points::driver >
 A test registration.
 
template<target_type Target>
using finalization = action< Target, test_control_points::finalization >
 A test finalization registration.
 
template<target_type Target>
using initialization = action< Target, test_control_points::initialization >
 A test initialization registration.
 

Assertion macros

Values to includes in a failure message may be streamed into an assertion:

EXPECT_GE(foo, 0) << foo << " should be non-negative";
#define EXPECT_GE(x, y)
Comparison.
Definition types.hh:347

Macros that begin with ASSERT are identical to their EXPECT counterparts except that they abandon the current UNIT (or innermost lambda within it) on failure (usually to avoid subsequent undefined behavior).

#define ASSERT_TRUE(c)
 Comparison.
 
#define EXPECT_TRUE(c)
 Comparison.
 
#define ASSERT_FALSE(c)
 Comparison.
 
#define EXPECT_FALSE(c)
 Comparison.
 
#define ASSERT_EQ(x, y)
 Comparison.
 
#define EXPECT_EQ(x, y)
 Comparison.
 
#define ASSERT_NE(x, y)
 Comparison.
 
#define EXPECT_NE(x, y)
 Comparison.
 
#define ASSERT_LT(x, y)
 Comparison.
 
#define EXPECT_LT(x, y)
 Comparison.
 
#define ASSERT_LE(x, y)
 Comparison.
 
#define EXPECT_LE(x, y)
 Comparison.
 
#define ASSERT_GT(x, y)
 Comparison.
 
#define EXPECT_GT(x, y)
 Comparison.
 
#define ASSERT_GE(x, y)
 Comparison.
 
#define EXPECT_GE(x, y)
 Comparison.
 
#define ASSERT_STREQ(x, y)
 Compare null-terminated strings, abandoning test on inequality.
 
#define EXPECT_STREQ(x, y)
 Check equality of null-terminated strings.
 
#define ASSERT_STRNE(x, y)
 Compare null-terminated strings, abandoning test on equality.
 
#define EXPECT_STRNE(x, y)
 Check inequality of null-terminated strings.
 
#define ASSERT_STRCASEEQ(x, y)
 Compare null-terminated strings, ignoring case and abandoning test on inequality.
 
#define EXPECT_STRCASEEQ(x, y)
 Check equality of null-terminated strings, ignoring case.
 
#define ASSERT_STRCASENE(x, y)
 Compare null-terminated strings, ignoring case and abandoning test on equality.
 
#define EXPECT_STRCASENE(x, y)
 Check inequality of null-terminated strings, ignoring case.
 

Detailed Description

Unit test framework much like Google Test but with task support.

Each Target is a function with signature int(); if any returns a non-zero value, so does the process built with flecsi_add_test. Output is via Logging.

Macro Definition Documentation

◆ UNIT

#define UNIT (   ...)

Define a unit test function.

Should be followed by a compound statement, which can use the other unit-testing macros, and a semicolon, and should generally appear alone in a function that returns int. Optionally, provide an expression convertible to std::string to label the test results (along with __func__); the default is "TEST".

Note
The ASSERT/EXPECT macros can be used in a lambda defined inside the compound statement with [&].

◆ ASSERT_TRUE

#define ASSERT_TRUE (   c)

Comparison.

◆ EXPECT_TRUE

#define EXPECT_TRUE (   c)

Comparison.

◆ ASSERT_FALSE

#define ASSERT_FALSE (   c)

Comparison.

◆ EXPECT_FALSE

#define EXPECT_FALSE (   c)

Comparison.

◆ ASSERT_EQ

#define ASSERT_EQ (   x,
 
)

Comparison.

◆ EXPECT_EQ

#define EXPECT_EQ (   x,
 
)

Comparison.

◆ ASSERT_NE

#define ASSERT_NE (   x,
 
)

Comparison.

◆ EXPECT_NE

#define EXPECT_NE (   x,
 
)

Comparison.

◆ ASSERT_LT

#define ASSERT_LT (   x,
 
)

Comparison.

◆ EXPECT_LT

#define EXPECT_LT (   x,
 
)

Comparison.

◆ ASSERT_LE

#define ASSERT_LE (   x,
 
)

Comparison.

◆ EXPECT_LE

#define EXPECT_LE (   x,
 
)

Comparison.

◆ ASSERT_GT

#define ASSERT_GT (   x,
 
)

Comparison.

◆ EXPECT_GT

#define EXPECT_GT (   x,
 
)

Comparison.

◆ ASSERT_GE

#define ASSERT_GE (   x,
 
)

Comparison.

◆ EXPECT_GE

#define EXPECT_GE (   x,
 
)

Comparison.

◆ ASSERT_STREQ

#define ASSERT_STREQ (   x,
 
)

Compare null-terminated strings, abandoning test on inequality.

◆ EXPECT_STREQ

#define EXPECT_STREQ (   x,
 
)

Check equality of null-terminated strings.

◆ ASSERT_STRNE

#define ASSERT_STRNE (   x,
 
)

Compare null-terminated strings, abandoning test on equality.

◆ EXPECT_STRNE

#define EXPECT_STRNE (   x,
 
)

Check inequality of null-terminated strings.

◆ ASSERT_STRCASEEQ

#define ASSERT_STRCASEEQ (   x,
 
)

Compare null-terminated strings, ignoring case and abandoning test on inequality.

◆ EXPECT_STRCASEEQ

#define EXPECT_STRCASEEQ (   x,
 
)

Check equality of null-terminated strings, ignoring case.

◆ ASSERT_STRCASENE

#define ASSERT_STRCASENE (   x,
 
)

Compare null-terminated strings, ignoring case and abandoning test on equality.

◆ EXPECT_STRCASENE

#define EXPECT_STRCASENE (   x,
 
)

Check inequality of null-terminated strings, ignoring case.

◆ UNIT_CAPTURE

#define UNIT_CAPTURE ( )

A stream that collects output for comparison.

◆ UNIT_DUMP

#define UNIT_DUMP ( )

Return captured output.

Returns
std::string

◆ UNIT_EQUAL_BLESSED

#define UNIT_EQUAL_BLESSED (   f)

Compare captured output to a blessed file.

Returns
bool

◆ UNIT_WRITE

#define UNIT_WRITE (   f)

Write captured output to file.

◆ UNIT_ASSERT

#define UNIT_ASSERT (   ASSERTION,
  ... 
)

Run an assertion and include captured output in any error message.

Parameters
ASSERTIONmacro name (TRUE, EQ, etc.)

Typedef Documentation

◆ initialization

template<target_type Target>
using initialization = action<Target, test_control_points::initialization>

A test initialization registration.

Declare a non-local variable of this type for each function.

Template Parameters
Targetthe function to call

◆ driver

template<target_type Target>
using driver = action<Target, test_control_points::driver>

A test registration.

Declare a non-local variable of this type for each function.

Template Parameters
Targetthe test function to call

◆ finalization

template<target_type Target>
using finalization = action<Target, test_control_points::finalization>

A test finalization registration.

Declare a non-local variable of this type for each function.

Template Parameters
Targetthe function to call