serial.reference
This macro needs to be put in front of any usage of the metal.serial
tool.
This macro provides printf-like output, where the actual formatting is done on the host side. It does required the passed parameters to declare there type.
METAL_SERIAL_PRINTF("%s - %d", STR("test"), INT(42));
Allowed types are:
-
BYTE
Bytes -
INT
Integers -
UINT
Unsigned integers -
STR
CStrings -
PTR
Pointers
The METAL_SERIAL_EXIT
provides a way to tell the tool the execution has finished while setting an explicit exit-code. This causes metal.serial
to exit as well. By default, metal.serial
will use the same exit-code.
This macros does the same as METAL_SERIAL_EXIT
but will take deduce the exit code from tests executed prior. That is, it metal.serial
will exit with 1 when any test failed, and 0 if all succeeded.
This macro enters a test case, which is important for the handling critical tests.
- Function The function
- Message The name of the test case as a string
\note This function uses a pointer and is not a template, so it can be defined in another place and reduces the amount of needed breakpoints. Though not used yet, it is reserved for future use. This might however be discarded, to any functionobject can be passed.
Example
void test_func()
{
METAL_SERIAL_ASSERT(some_test());
}
int main(int argc, char * argv[])
{
METAL_SERIAL_INIT();
METAL_SERIAL_CALL(&test_func, "first test func");
METAL_SERIAL_CALL(+[]{METAL_SERIAL_ASSERT(something_else);}, "lambda case");
METAL_SERIAL_TEST_EXIT();
return 0;
}
This macro provides a assertion with a custom error message. The plain \ref METAL_SERIAL_ASSERT will output the code given as the condition.
- Condition The condition to be checked.
- Message the custom message.
Example
std::string str;
METAL_SERIAL_ASSERT_MESSAGE(str.empty(), "string empty");
See also
This macro provides a expectation with a custom error message. The plain #METAL_SERIAL_EXPECT will output the code given as the condition.
- Condition The condition to be checked.
- Message the custom message.
Example
std::string str;
METAL_SERIAL_EXPECT_MESSAGE(str.empty(), "string empty");
See also
This macro provides a plain assertion.
- Condition The condition to be checked.
Example
std::string str = "some data";
METAL_SERIAL_ASSERT(str.empty());
See also
This macro provides a plain expectation.
- Condition The condition to be checked.
Example
std::string str = "some data";
METAL_SERIAL_EXPECT(str.empty(), "string empty");
See also
METAL_SERIAL_ASSERT_EQUAL(15, 0xF);
See also
This test expects the equality of two values, through operator==
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
Example
METAL_SERIAL_EXPECT_EQUAL(15, 0xF);
See also
This test asserts the equality of two values, through operator==
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
Example
METAL_SERIAL_ASSERT_NOT_EQUAL(15, 0xF);
See also
This test expects the equality of two values, through operator!=
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
Example
METAL_SERIAL_EXPECT_NOT_EQUAL(15, 0xF);
See also
This test expects Lhs to be greater or equal to Rhs, through operator>=
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
Example
METAL_SERIAL_EXPECT_GE(15, 0xF);
See also
This test expects Lhs to be greater or equal to Rhs, through operator>=
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
METAL_SERIAL_ASSERT_GE(4, 0b100);
See also
This test expects Lhs to be lesser or equal to Rhs, through operator<=
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
Example
METAL_SERIAL_EXPECT_LE(15, 0xF);
See also
This test expects Lhs to be lesser or equal to Rhs, through operator<=
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
METAL_SERIAL_ASSERT_LE(4, 0b100);
See also
This test expects Lhs to be greater than Rhs, through operator>
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
Example
METAL_SERIAL_EXPECT_GREATER(15, 0xE);
See also
This test expects Lhs to be greater than Rhs, through operator>
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
METAL_SERIAL_ASSERT_GREATER(4, 0b10);
See also
This test expects Lhs to be lesser than Rhs, through operator>
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
Example
METAL_SERIAL_EXPECT_LESSER(13, 0xF);
See also
This test expects Lhs to be lesser than Rhs, through operator>
.
It provides output of the actual values when used in hosted mode.
- Lhs Left hand-side value to compare.
- Rhs Right hand-side value to compare.
METAL_SERIAL_ASSERT_LESSER(1, 0b100);
See also
This macro can be used to assert a certain line is not executed. Fails when executed.
**Example **
if (false)
METAL_SERIAL_ASSERT_NO_EXECUTE()
See also
This macro can be used to assert a certain line is not executed. Fails when executed.
**Example **
if (false)
METAL_SERIAL_EXPECT_NO_EXECUTE()
See also
- Overview
- Runner Introduction
- Runner Invocation
- Runner Plugins
- Runner Extender
- Runner FAQ
- Runner Reference
- Unit Introduction
- Unit Tutorial
- Unit FAQ
- Unit Reference
- Calltrace Introduction
- Calltrace Tutorial
- Calltrace FAQ
- Calltrace Plugin
- Calltrace Reference
- Serial Introduction
- Serial Tutorial
- Serial Invocation
- Serial Reference