Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

unit.reference

Klemens David Morgenstern edited this page Apr 4, 2018 · 3 revisions

METAL_ERROR()

This macro yields a logical true (might be int) if the last check was unsuccsessful.

Example

std::string str = get_str();
METAL_EXPECT(str.empty());
if (METAL_ERROR()) 
    METAL_LOG("Empty String");

See also

METAL_STATUS()

This macro yields a logical true (might be int) if the last check was succsessful.

Example

const char * str = get_str();
METAL_EXPECT_NOT_EQUAL(str, nullptr);
if (METAL_STATUS())
{
    const char cmp[15] = "compare string";
    METAL_ASSERT_EQUAL_RANGED(str, str + std::strlen(str), cmp, cmp + 15);
}

See also

METAL_ERRORED()

This macro yields a logical true (might be int) if an error occured anywhere up to this point.

Example

METAL_CALL(&my_test_case, "my test case");
if (METAL_ERRORED())
    clean_up();

See also

METAL_IS_CRITICAL()

This macro yields a logical true (might be int) if the current environment is critical. That means, that all tests being executed will cause canceling of the current test case if it fails.

\note This may be used as a replacement if the test is executed in standalone mode.

Example

if (!METAL_IS_CRITICAL())
    METAL_ASSERT(some_test());

See also

METAL_CALL(Function, Message)

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_ASSERT(some_test());
}

int main(int argc, char * argv[])
{
    METAL_CALL(&test_func, "first test func");
    METAL_CALL(+[]{METAL_ASSERT(something_else);}, "lambda case");
    return METAL_REPORT();
}

METAL_REPORT()

This macro returns zero when no error occured and non-zero for any error. It is meant to be used in the main-function of the test as the return value.

In hosted mode the return value may be manipulated, if the test runner needs to ignore the return value.

Example:

int main(int argc, char * argv[])
{
    METAL_ASSERT(some_test());
    return METAL_REPORT();
}

METAL_BITWISE_EXPR(Lhs, Rhs, Oper, Chain)

This macro does provide the implementation for bitwise operations, done through the shift-operator. It can be used to add more tests if necessary. The operator will just be paste between the shifted values. The Chain parameter is necessary, since the logic can be different. I.e. when comparing two values bitwise, all of the bits need to be equal, while when comparing to not equal, one difference is enough. Hence equal has && as chain operator, while not equal uses ||.

  • Lhs Left hand side of the operation
  • Rhs Right hand side of the operation
  • Oper the actual operation
  • Chain the connection of the bitwise steps. \return A logical boolean value containing the result.

Example

#define METAL_EQUAL_BITWISE(Lhs, Rhs)     METAL_BITWISE(Lhs, Rhs, ==, &&, __metal_oper_equal)
#define METAL_NOT_EQUAL_BITWISE(Lhs, Rhs) METAL_BITWISE(Lhs, Rhs, != , ||, __metal_oper_not_equal);

METAL_STATIC_ASSERT(Condition, Message)

This macro provides a statis assertion, i.e. a test done without execution.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

  • Condition the condition to be asserted
  • Message to be outputted.
METAL_STATIC_ASSERT(42 > 0, "dummy test");

METAL_LOG(Message)

Output a log message.

\warning Does nothing in standalone mode.

See also

METAL_CHECKPOINT()

This macro puts in a checkpoint, so the output documents this.

See also

METAL_ASSERT_MESSAGE(Condition, Message)

This macro provides a assertion with a custom error message. The plain \ref METAL_ASSERT will output the code given as the condition.

  • Condition The condition to be checked.
  • Message the custom message.

Example

std::string str;
METAL_ASSERT_MESSAGE(str.empty(), "string empty");

See also

METAL_EXPECT_MESSAGE(Condition, Message)

This macro provides a expectation with a custom error message. The plain #METAL_EXPECT will output the code given as the condition.

  • Condition The condition to be checked.
  • Message the custom message.

Example

std::string str;
METAL_EXPECT_MESSAGE(str.empty(), "string empty");

See also

METAL_ASSERT(Condition)

This macro provides a plain assertion.

  • Condition The condition to be checked.

Example

std::string str = "some data";
METAL_ASSERT(str.empty());

See also

METAL_EXPECT(Condition)

This macro provides a plain expectation.

  • Condition The condition to be checked.

Example

std::string str = "some data";
METAL_EXPECT(str.empty(), "string empty");

See also

METAL_ASSERT_PREDICATE(Function, Args...)

This macro provides an expectation based on a predicate. It provides more detailed output than \bb_macro{METAL_ASSERT}.

  • Function The condition to be checked.
  • Args... The arguments for the predicate call.

Example

auto predicate = [](int x, int y, int z) {return (x*y) < z;};
METAL_ASSERT_PREDICATE(predicate, 10, 2, 30);

See also

METAL_EXPECT_PREDICATE(Function, Args...)

This macro provides an expectation based on a predicate. It provides more detailed output than METAL_EXPECT.

  • Function The condition to be checked.
  • Args... The arguments for the predicate call.

Example

auto predicate = [](int x, int y, int z) {return (x*y) < z;};
METAL_EXPECT_PREDICATE(predicate, 10, 2, 30);

See also

METAL_STATIC_ASSERT_PREDICATE(Function, Args...)

A static test version of METAL_ASSERT_PREDICATE.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

  • Function The condition to be checked.
  • Args... The arguments for the predicate call.

Example

constexpr bool predicate(int x, int y, int z) {return (x*y) < z;}

METAL_STATIC_ASSERT_PREDICATE(predicate, x, y, z);

See also

METAL_ASSERT_EQUAL(Lhs, Rhs)

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_ASSERT_EQUAL(15, 0xF);

See also

METAL_EXPECT_EQUAL(Lhs, Rhs)

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_EXPECT_EQUAL(15, 0xF);

See also

METAL_EXPECT_EQUAL_BITWISE(Lhs, Rhs)

This test expects the equality of every bit in the given values. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if every bit in Lhs is equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

*The behaviour of shifting signed values is implementation defined. *

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_EXPECT_EQUAL_BITWISE(0b10, 2);

See also

METAL_ASSERT_EQUAL_BITWISE(Lhs, Rhs)

This test expects the equality of every bit in the given values. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if every bit in Lhs is equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

*The behaviour of shifting signed values is implementation defined. *

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_ASSERT_EQUAL_BITWISE(0b10, 2);

See also

METAL_STATIC_ASSERT_EQUAL(Lhs, Rhs)

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.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_EQUAL(3, 0b11);

See also

METAL_STATIC_ASSERT_EQUAL_BITWISE(Lhs, Rhs)

This macro provides a bitwise version of METAL_STATIC_ASSERT_EQUAL.

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_EQUAL_BITWISE(3, 0b11);

See also

METAL_ASSERT_NOT_EQUAL(Lhs, Rhs)

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_ASSERT_NOT_EQUAL(15, 0xF);

See also

METAL_EXPECT_NOT_EQUAL(Lhs, Rhs)

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_EXPECT_NOT_EQUAL(15, 0xF);

See also

METAL_EXPECT_NOT_EQUAL_BITWISE(Lhs, Rhs)

This test expects the equality of every bit in the given values. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if any bit in Lhs is not equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

*The behaviour of shifting signed values is implementation defined. *

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_EXPECT_NOT_EQUAL_BITWISE(0b10, 1);

See also

METAL_ASSERT_NOT_EQUAL_BITWISE(Lhs, Rhs)

This test expects the equality of every bit in the given values. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if any bit in Lhs is not equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

*The behaviour of shifting signed values is implementation defined. *

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_ASSERT_NOT_EQUAL_BITWISE(0b10, 1);

See also

METAL_STATIC_ASSERT_NOT_EQUAL(Lhs, Rhs)

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.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_NOT_EQUAL(2, 0b11);

See also

METAL_STATIC_ASSERT_NOT_EQUAL_BITWISE(Lhs, Rhs)

This macro provides a bitwise version of METAL_STATIC_ASSERT_NOT_EQUAL.

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_NOT_EQUAL_BITWISE(0b10, 0b11);

See also

METAL_EXPECT_CLOSE(Lhs, Rhs, Tolerance)

This test expects Rhs to be within an absolute tolerance to Lhs, i.e. Lhs = Rhs +/- Tolerance.

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

Example

METAL_EXPECT_CLOSE(1.0, 1.2, 0.2);

See also.

METAL_ASSERT_CLOSE(Lhs, Rhs, Tolerance)

This test assert Rhs to be within an absolute tolerance to Lhs, i.e. Lhs = Rhs +/- Tolerance.

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

Example

METAL_ASSERT_CLOSE(1.0, 1.2, 0.2);

See also.

METAL_STATIC_ASSERT_CLOSE(Lhs, Rhs, Tolerance)

This static test assert Rhs to be within an absolute tolerance to Lhs, i.e. Lhs = Rhs +/- Tolerance.

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_CLOSE(1.0, 1.2, 0.2);

See also.

METAL_EXPECT_CLOSE_RELATIVE(Lhs, Rhs, Tolerance)

This test expects Rhs to be within a relative tolerance to Lhs, i.e. Lhs = Rhs +/- (Lhs * Tolerance).

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

Example

METAL_EXPECT_CLOSE_RELATIVE(2.0, 1.5, 0.25);

See also.

METAL_ASSERT_CLOSE_RELATIVE(Lhs, Rhs, Tolerance)

This test assert Rhs to be within a relative tolerance to Lhs, i.e. Lhs = Rhs +/- (Lhs * Tolerance).

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

Example

METAL_ASSERT_CLOSE_RELATIVE(5.0, 0.5, 0.1);

See also.

METAL_STATIC_ASSERT_CLOSE_RELATIVE(Lhs, Rhs, Tolerance)

This static test assert Rhs to be within a relative tolerance to Lhs, i.e. Lhs = Rhs +/- (Lhs * Tolerance).

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_CLOSE_RELATIVE(2.0, 1.8, 0.1);

See also.

METAL_EXPECT_CLOSE_PERCENT(Lhs, Rhs, Tolerance)

This test expects Rhs to be within a relative tolerance to Lhs, i.e. Lhs = Rhs +/- (Lhs * Tolerance %).

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

Example

METAL_EXPECT_CLOSE_PERCENT(2.0, 1.5, 25);

See also.

METAL_ASSERT_CLOSE_PERCENT(Lhs, Rhs, Tolerance)

This test assert Rhs to be within a relative tolerance to Lhs, i.e. Lhs = Rhs +/- (Lhs * Tolerance %).

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

Example

METAL_ASSERT_CLOSE_PERCENT(5.0, 0.5, 10);

See also.

METAL_STATIC_ASSERT_CLOSE_PERCENT(Lhs, Rhs, Tolerance)

This static test assert Rhs to be within a relative tolerance to Lhs, i.e. Lhs = Rhs +/- (Lhs * Tolerance %).

  • Lhs hand-side value to compare
  • Rhs hand-side value to compare
  • Tolerance The tolerated distance between Rhs and Lhs.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_CLOSE_PERCENT(2.0, 1.8, 10);

See also.

METAL_EXPECT_GE(Lhs, Rhs)

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_EXPECT_GE(15, 0xF);

See also

METAL_ASSERT_GE(Lhs, Rhs)

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_ASSERT_GE(4, 0b100);

See also

METAL_EXPECT_GE_BITWISE(Lhs, Rhs)

This test expects the every bit of Lhs to be greater or equal to the corresponding in Rhs. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if every bit in Lhs is equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

The behaviour of shifting signed values is implementation defined.

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_EXPECT_GE_BITWISE(0b10, 2);

See also

METAL_ASSERT_GE_BITWISE(Lhs, Rhs)

This test expects the every bit of Lhs to be greater or equal to the corresponding in Rhs. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if every bit in Lhs is equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

*The behaviour of shifting signed values is implementation defined. *

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_ASSERT_GE_BITWISE(0b10, 2);

See also

METAL_STATIC_ASSERT_GE(Lhs, Rhs)

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.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_GE(3, 0b11);

See also

METAL_STATIC_ASSERT_GE_BITWISE(Lhs, Rhs)

This macro provides a bitwise version of METAL_STATIC_ASSERT_GE.

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_GE_BITWISE(3, 0b11);

See also

METAL_EXPECT_LE(Lhs, Rhs)

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_EXPECT_LE(15, 0xF);

See also

METAL_ASSERT_LE(Lhs, Rhs)

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_ASSERT_LE(4, 0b100);

See also

METAL_EXPECT_LE_BITWISE(Lhs, Rhs)

This test expects the every bit of Lhs to be lesser or equal to the corresponding in Rhs. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if every bit in Lhs is equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

*The behaviour of shifting signed values is implementation defined. *

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_EXPECT_LE_BITWISE(0b10, 2);

See also

METAL_ASSERT_LE_BITWISE(Lhs, Rhs)

This test expects the every bit of Lhs to be lesser or equal to the corresponding in Rhs. The values given must have an operator<< and an operator& defined. The maximum size is 8 bytes.

This test will succeed if every bit in Lhs is equal to the bit in Rhs at the same position.

In hosted mode the output will also be done in binary notation.

*The behaviour of shifting signed values is implementation defined. *

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

Example

METAL_ASSERT_LE_BITWISE(0b10, 2);

See also

METAL_STATIC_ASSERT_LE(Lhs, Rhs)

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.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_LE(3, 0b11);

See also

METAL_STATIC_ASSERT_LE_BITWISE(Lhs, Rhs)

This macro provides a bitwise version of METAL_STATIC_ASSERT_LE.

  • Lhs Left hand-side value to compare.
  • Rhs Right hand-side value to compare.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_LE_BITWISE(3, 0b11);

See also

METAL_EXPECT_GREATER(Lhs, Rhs)

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_EXPECT_GREATER(15, 0xE);

See also

METAL_ASSERT_GREATER(Lhs, Rhs)

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_ASSERT_GREATER(4, 0b10);

See also

METAL_STATIC_ASSERT_GREATER(Lhs, Rhs)

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.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_GREATER(3, 0b10);

See also

METAL_EXPECT_LESSER(Lhs, Rhs)

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_EXPECT_LESSER(13, 0xF);

See also

METAL_ASSERT_LESSER(Lhs, Rhs)

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_ASSERT_LESSER(1, 0b100);

See also

METAL_STATIC_ASSERT_LESSER(Lhs, Rhs)

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.

*Currently this test is done at compiletime, so that all the other tests cannot be executed on fail. This may change in a future version. *

Example

METAL_STATIC_ASSERT_LESSER(2, 0b11);

See also

METAL_ASSERT_EQUAL_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides an equality assertion for two ranges.

It succeeds if every element in the left-handside container is equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_EQUAL_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

\code{.c} int rhs[3] = {1,2,3}; int lhs[3] = {1,2,3}; METAL_ASSERT_EQUAL_RANGED(rhs, 3, lhs, 3);


**See also**
  * [METAL_ASSERT_EQUAL](#metal_assert_equal)    
  * [METAL_EXPECT_EQUAL](#metal_expect_equal)    
  * [METAL_EXPECT_EQUAL_RANGED](#metal_expect_equal_ranged)    
  * [METAL_STATIC_ASSERT_EQUAL](#metal_static_assert_equal)    
  * [METAL_STATIC_ASSERT_EQUAL_BITWISE](#metal_static_assert_equal_bitwise)    
  * [METAL_ASSERT_EQUAL_BITWISE](#metal_assert_equal_bitwise)   
  * [METAL_EXPECT_EQUAL_BITWISE](#metal_expect_equal_bitwise)   
  * [METAL_ASSERT_EQUAL_BITWISE_RANGED](#metal_assert_equal_bitwise_ranged)   
  * [METAL_EXPECT_EQUAL_BITWISE_RANGED](#metal_expect_equal_bitwise_ranged) 

# METAL_EXPECT_EQUAL_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides an equality expectation for two ranges. 

It succeeds if every element in the left-handside container is equal 
to the one the right side.

 * LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
 * LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
 * RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
 * RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.
 
**Example C++**

```cpp
std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_EXPECT_EQUAL_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,2,3};
int lhs[3] = {1,2,3};
METAL_EXPECT_EQUAL_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_EQUAL_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise equality assertion for two ranges.

It succeeds if every element in the left-handside container is equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_EQUAL_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,2,3};
int lhs[3] = {1,2,3};
METAL_ASSERT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_EQUAL_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise equality expectation for two ranges.

It succeeds if every element in the left-handside container is equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_EXPECT_EQUAL_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,2,3};
int lhs[3] = {1,2,3};
METAL_EXPECT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_NOT_EQUAL_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides an inequality assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_NOT_EQUAL_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,2,3};
int lhs[3] = {1,2,3};
METAL_ASSERT_NOT_EQUAL_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_NOT_EQUAL_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides an inequality expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_EXPECT_NOT_EQUAL_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,2,3};
int lhs[3] = {1,2,3};
METAL_EXPECT_NOT_EQUAL_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_NOT_EQUAL_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise inequality assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_NOT_EQUAL_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,2,3};
int lhs[3] = {1,2,3};
METAL_ASSERT_NOT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_NOT_EQUAL_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise inequality expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,2,3};
METAL_EXPECT_NOT_EQUAL_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,2,3};
int lhs[3] = {1,2,3};
METAL_EXPECT_NOT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_CLOSE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd, Tolerance)

This macro provides a bitwise equality assertion for two ranges with a tolerance.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.
  • Tolerance The tolerance of the comparison

Example C++

std::vector<int> rhs = {11,22,33};
std::vector<int> lhs = {12,23,32};
METAL_ASSERT_CLOSE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end(), 1);

Example C

int rhs[3] = {12,25,37};
int lhs[3] = {13,24,36};
METAL_ASSERT_CLOSE_RANGED(rhs, 3, lhs, 3, 1);

See also.

METAL_EXPECT_CLOSE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd, Tolerance)

This macro provides a bitwise equality expectation for two ranges with a tolerance.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.
  • Tolerance The tolerance of the comparison

Example C++

std::vector<int> rhs = {11,22,33};
std::vector<int> lhs = {12,23,32};
METAL_EXPECT_CLOSE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end(), 1);

Example C

int rhs[3] = {12,25,37};
int lhs[3] = {13,24,36};
METAL_EXPECT_CLOSE_RANGED(rhs, 3, lhs, 3, 1);

See also.

METAL_ASSERT_CLOSE_RELATIVE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd, Tolerance)

This macro provides a bitwise equality assertion for two ranges with a relative tolerance.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.
  • Tolerance The tolerance of the comparison

Example C++

std::vector<double> rhs = {1.0, 2.0, 3.0};
std::vector<double> lhs = {1.1, 1.8, 3.3};
METAL_ASSERT_CLOSE_RELATIVE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end(), 0.1);

Example C

double rhs[3] = {1.0, 2.0, 3.0};
double lhs[3] = {0.9, 2.2, 2.7};
METAL_ASSERT_NOT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3, 0.1);

See also.

METAL_EXPECT_CLOSE_RELATIVE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd, Tolerance)

This macro provides a bitwise equality expectation for two ranges with a relative tolerance.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.
  • Tolerance The tolerance of the comparison

Example C++

std::vector<double> rhs = {1.0, 2.0, 3.0};
std::vector<double> lhs = {1.1, 1.8, 3.3};
METAL_ASSERT_CLOSE_RELATIVE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end(), 0.1);

Example C

double rhs[3] = {1.0, 2.0, 3.0};
double lhs[3] = {0.9, 2.2, 2.7};
METAL_ASSERT_NOT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3, 0.1);

See also.

METAL_ASSERT_CLOSE_PERCENT_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd, Tolerance)

This macro provides a bitwise equality assertion for two ranges with a relative tolerance in percent.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.
  • Tolerance The tolerance of the comparison

Example C++

std::vector<double> rhs = {1.0, 2.0, 3.0};
std::vector<double> lhs = {1.1, 1.8, 3.3};
METAL_ASSERT_CLOSE_PERCENT_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end(), 10);

Example C

double rhs[3] = {1.0, 2.0, 3.0};
double lhs[3] = {0.9, 2.2, 2.7};
METAL_ASSERT_NOT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3, 10);

See also.

METAL_EXPECT_CLOSE_PERCENT_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd, Tolerance)

This macro provides a bitwise equality expectation for two ranges with a relative tolerance in percent.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.
  • Tolerance The tolerance of the comparison

Example C++

std::vector<double> rhs = {1.0, 2.0, 3.0};
std::vector<double> lhs = {1.1, 1.8, 3.3};
METAL_ASSERT_CLOSE_PERCENT_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end(), 10);

Example C

double rhs[3] = {1.0, 2.0, 3.0};
double lhs[3] = {0.9, 2.2, 2.7};
METAL_ASSERT_NOT_EQUAL_BITWISE_RANGED(rhs, 3, lhs, 3, 10);

See also.

METAL_ASSERT_GE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a greater or equal assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,4,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_GE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,4,3};
int lhs[3] = {1,2,3};
METAL_ASSERT_GE_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_GE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a greater or equal expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,3,3};
std::vector<int> lhs = {1,2,3};
METAL_EXPECT_GE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,3,3};
int lhs[3] = {1,2,3};
METAL_EXPECT_GE_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_GE_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise greater or equal assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,3,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_GE_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,3,3};
int lhs[3] = {1,2,3};
METAL_ASSERT_GE_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_GE_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise greater or equal expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,1,1};
METAL_EXPECT_GE_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,3,3};
int lhs[3] = {1,2,3};
METAL_EXPECT_GE_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_LE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a lesser or equal assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,1,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_LE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,1,3};
int lhs[3] = {1,2,3};
METAL_ASSERT_LE_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_LE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a lesser or equal expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,1,3};
std::vector<int> lhs = {1,2,3};
METAL_EXPECT_LE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,1,3};
int lhs[3] = {1,2,3};
METAL_EXPECT_LE_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_LE_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise lesser or equal assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,1,3};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_LE_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,1,3};
int lhs[3] = {1,2,3};
METAL_ASSERT_LE_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_LE_BITWISE_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a bitwise lesser or equal expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {1,2,3};
std::vector<int> lhs = {1,3,4};
METAL_EXPECT_LE_BITWISE_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,3,3};
int lhs[3] = {1,4,3};
METAL_EXPECT_LE_BITWISE_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_GREATER_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a greater than assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {2,4,4};
std::vector<int> lhs = {1,2,3};
METAL_ASSERT_GREATER_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {3,4,7};
int lhs[3] = {1,2,3};
METAL_ASSERT_GREATER_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_GREATER_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a greater than expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {2,3,3};
std::vector<int> lhs = {1,2,3};
METAL_EXPECT_GREATER_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,3,3};
int lhs[3] = {0,2,2};
METAL_EXPECT_GREATER_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_LESSER_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a lesser than assertion for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {2,4,4};
std::vector<int> lhs = {3,5,6};
METAL_ASSERT_LESSER_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {3,4,7};
int lhs[3] = {4,5,8};
METAL_ASSERT_LESSER_RANGED(rhs, 3, lhs, 3);

See also

METAL_EXPECT_LESSER_RANGED(LhsBegin, LhsEnd, RhsBegin, RhsEnd)

This macro provides a lesser than expectation for two ranges.

It succeeds if one element in the left-handside container is not equal to the one the right side.

  • LhsBegin The begin of the left-hand-side range. In C this is a pointer to an array.
  • LhsEnd The end of the left-hand-side range (behind the last element). In C this is the size of the array.
  • RhsBegin The begin of the right-hand-side range. In C this is a pointer to an array.
  • RhsEnd The end of the right-hand-side range (behind the last element). In C this is the size of the array.

Example C++

std::vector<int> rhs = {2,3,3};
std::vector<int> lhs = {3,4,5};
METAL_EXPECT_LESSER_RANGED(rhs.begin(), rhs.end(), lhs.begin(), lhs.end());

Example C

int rhs[3] = {1,3,3};
int lhs[3] = {0,2,2};
METAL_EXPECT_LESSER_RANGED(rhs, 3, lhs, 3);

See also

METAL_ASSERT_THROW(Code, Exceptions...)

This macro does provide an assertion for an exception of a set of types. It fails if no exception or an exception not in the list (except inheriting exceptions) are thrown. If the required code includes commas, it might not compile correctly. To allow this the try and catch expressions can be seperated using \xmlonly METAL_ENTER_TRY and \xmlonly METAL_ASSERT_THROW_EXIT \endxmlonly.

\note An exception not listed will still be caught.

  • Code The code to be executed
  • Exceptions... The set of exceptions.

Example

METAL_ASSERT_THROW(std::stoi("invalid string"), std::out_of_range, std::invalid_range);    
METAL_ASSERT_THROW(std::stoi("123987789234789897234"), std::out_of_range, std::invalid_range);    

See also

METAL_EXPECT_THROW(Code, Exceptions...)

This macro does provide an expectation for an exception of a set of types. It fails if no exception or an exception not in the list (except inheriting exceptions) are thrown. If the required code includes commas, it might not compile correctly. To allow this the try and catch expressions can be seperated using \xmlonly METAL_ENTER_TRY and \xmlonly METAL_EXPECT_THROW_EXIT \endxmlonly.

\note An exception not listed will still be caught.

  • Code The code to be executed
  • Exceptions... The set of exceptions.

Example

METAL_EXPECT_THROW(std::stoi("invalid string"), std::out_of_range, std::invalid_range);    
METAL_EXPECT_THROW(std::stoi("123987789234789897234"), std::out_of_range, std::invalid_range);    

See also

METAL_ASSERT_ANY_THROW(Code)

This macro does provide an assertion for the throw of any exception. If the required code includes commas, it might not compile correctly. To allow this the try and catch expressions can be seperated using \xmlonly METAL_ENTER_TRY and \xmlonly METAL_ASSERT_ANY_THROW_EXIT \endxmlonly.

  • Code The code to be executed

Example

METAL_ASSERT_ANY_THROW(std::stoi("invalid string"));

See also

METAL_EXPECT_ANY_THROW(Code)

This macro does provide an assertion for the throw of any exception. If the required code includes commas, it might not compile correctly. To allow this the try and catch expressions can be seperated using \xmlonly METAL_ENTER_TRY and \xmlonly METAL_EXPECT_ANY_THROW_EXIT \endxmlonly.

  • Code The code to be executed

Example

METAL_EXPECT_ANY_THROW(std::stoi("invalid string"));

See also

METAL_ASSERT_NO_THROW(Code)

This macro does provide an assertion for the throw of no exception. If the required code includes commas, it might not compile correctly. To allow this the try and catch expressions can be seperated using \xmlonly METAL_ENTER_TRY and \xmlonly METAL_ASSERT_NO_THROW_EXIT \endxmlonly.

  • Code The code to be executed

Example

METAL_ASSERT_NO_THROW(std::stoi("42"));

See also

METAL_EXPECT_NO_THROW(Code)

This macro does provide an assertion for the throw of no exception. If the required code includes commas, it might not compile correctly. To allow this the try and catch expressions can be seperated using \xmlonly METAL_ENTER_TRY and \xmlonly METAL_EXPECT_NO_THROW_EXIT \endxmlonly.

  • Code The code to be executed

Example

METAL_EXPECT_NO_THROW(std::stoi("42"));

See also

METAL_ENTER_TRY()

This macro is for seperate exceptions tests, i.e. if longer code shall be used.

It expands to try {, but documents the intent much clearer.

The seperated syntax is used, when the

Example

METAL_TRY()
    int i,j;
    i = std::stoi("42");
    j = std::stoi("12"); 
METAL_ASSERT_NO_THROW();

See also

METAL_ASSERT_THROW_EXIT(Exceptions...)

This macro provides an assertion for an exception of a set of types. It fails if no exception or an exception not in the list (except inheriting exceptions) are thrown. This is the seperate form of \xmlonly METAL_ASSERT_THROW \endxmlonly.

\note An exception not listed will still be caught.

  • Exceptions... The set of exceptions.

Example

METAL_ENTER_TRY()
    int i, j; 
    i = std::stoi("invalid string"); 
    j = std::stoi("123987789234789897234");    
METAL_ASSERT_THROW_EXIT(std::out_of_range, std::invalid_range)

See also

METAL_EXPECT_THROW_EXIT(Exceptions...)

This macro provides an expectation for an exception of a set of types. It fails if no exception or an exception not in the list (except inheriting exceptions) are thrown. This is the seperate form of \xmlonly METAL_EXPECT_THROW \endxmlonly.

\note An exception not listed will still be caught.

  • Exceptions... The set of exceptions.

Example

METAL_ENTER_TRY()
    int i, j; 
    i = std::stoi("invalid string"); 
    j = std::stoi("123987789234789897234");    
METAL_EXPECT_THROW_EXIT(std::out_of_range, std::invalid_range)

See also

METAL_ASSERT_ANY_THROW_EXIT()

This macro provides an assertion for the throw of any exception. This is the seperate form of \xmlonly METAL_ASSERT_ANY_THROW \endxmlonly.

Example

METAL_ENTER_TRY()
    int i = std::stoi("invalid string");
METAL_ASSERT_ANY_THROW_EXIT();

See also

METAL_EXPECT_ANY_THROW_EXIT()

This macro provides an assertion for the throw of any exception. This is the seperate form of \xmlonly METAL_EXPECT_ANY_THROW \endxmlonly.

Example

METAL_ENTER_TRY()
    int i = std::stoi("invalid string");
METAL_EXPECT_ANY_THROW_EXIT();

See also

METAL_ASSERT_NO_THROW_EXIT()

This macro provides an assertion for the throw of no exception. This is the seperate form of \xmlonly METAL_ASSERT_NO_THROW \endxmlonly.

Example

METAL_ENTER_TRY()
    int i = std::stoi("42");
METAL_ASSERT_NO_THROW_EXIT()

See also

METAL_EXPECT_NO_THROW_EXIT()

This macro provides an assertion for the throw of no exception. This is the seperate form of \xmlonly METAL_EXPECT_NO_THROW \endxmlonly.

Example

METAL_ENTER_TRY()
    int i = std::stoi("42");
METAL_EXPECT_NO_THROW_EXIT()

See also

METAL_ASSERT_EXECUTE()

This macro can be used to assert the execution of a certain line.

\warning At the current state this must be validated in the output.

See also

METAL_EXPECT_EXECUTE()

This macro can be used to expect the execution of a certain line.

\warning At the current state this must be validated in the output.

See also

METAL_ASSERT_NO_EXECUTE()

This macro can be used to assert a certain line is not executed. Fails when executed.

**Example **

if (false)
    METAL_ASSERT_NO_EXECUTE()

See also

METAL_EXPECT_NO_EXECUTE()

This macro can be used to assert a certain line is not executed. Fails when executed.

**Example **

if (false)
    METAL_EXPECT_NO_EXECUTE()

See also

METAL_CRITICAL(Check)

This macro declares an expression as a critical test. This means, that in hosted mode, the current test case will be aborted.

  • Critical test abortion on fail does only work in hosted mode.*

  • Check The actual check

Example

METAL_CRITICAL(METAL_ASSERT(true));

See also

METAL_ENTER_CRITICAL()

This macro provides entering a critical section, when more than one tests shall be critical at once.

Example

METAL_ENTER_CRITICAL()
    METAL_ASSERT(true);
    METAL_EXPECT_EQUAL(42, 0x2A);
METAL_EXIT_CRITICAL()

See also

METAL_EXIT_CRITICAL()

This macro provides entering a critical section, when more than one tests shall be critical at once.

Example

METAL_ENTER_CRITICAL()
    METAL_ASSERT(true);
    METAL_EXPECT_EQUAL(42, 0x2A);
METAL_EXIT_CRITICAL()

See also

Clone this wiki locally