TTS v4.1.0
The Tiny Test System
Loading...
Searching...
No Matches
Relation Tests Macros

Macros for performing relation checks. More...

Runtime Relation Checks

#define TTS_BIT_EQUAL(LHS, RHS, ...)
 Checks that two expressions have the same bits.
#define TTS_BIT_NOT_EQUAL(LHS, RHS, ...)
 Checks that two expressions have different bits.
#define TTS_EQUAL(LHS, RHS, ...)
 Checks that two expressions are equal.
#define TTS_NOT_EQUAL(LHS, RHS, ...)
 Checks that two expressions are not equal.
#define TTS_LESS(LHS, RHS, ...)
 Checks that LHS is less than RHS.
#define TTS_GREATER(LHS, RHS, ...)
 Checks that LHS is greater than RHS.
#define TTS_LESS_EQUAL(LHS, RHS, ...)
 Checks that LHS is less than or equal to RHS.
#define TTS_GREATER_EQUAL(LHS, RHS, ...)
 Checks that LHS is greater than or equal to RHS.

Runtime Typed Relation Checks

#define TTS_TYPED_EQUAL(LHS, RHS, ...)
 Checks that two expressions are of the same type and that they are equal.
#define TTS_TYPED_NOT_EQUAL(LHS, RHS, ...)
 Checks that two expressions are of the same type and that they are not equal.
#define TTS_TYPED_LESS(LHS, RHS, ...)
 Checks that two expressions are of the same type and that LHS is less than RHS.
#define TTS_TYPED_GREATER(LHS, RHS, ...)
 Checks that two expressions are of the same type and that LHS is greater than RHS.
#define TTS_TYPED_LESS_EQUAL(LHS, RHS, ...)
 Checks that two expressions are of the same type and that LHS is less than or equal to RHS.
#define TTS_TYPED_GREATER_EQUAL(LHS, RHS, ...)
 Checks that two expressions are of the same type and that LHS is greater than or equal to RHS.

Constexpr Relation Checks

#define TTS_CONSTEXPR_EQUAL(LHS, RHS, ...)
 Checks at compile time that two constant expressions are equal.
#define TTS_CONSTEXPR_NOT_EQUAL(LHS, RHS, ...)
 Checks at compile time that two constant expressions are not equal.
#define TTS_CONSTEXPR_LESS(LHS, RHS, ...)
 Checks at compile time that LHS is less than RHS.
#define TTS_CONSTEXPR_GREATER(LHS, RHS, ...)
 Checks at compile time that LHS is greater than RHS.
#define TTS_CONSTEXPR_LESS_EQUAL(LHS, RHS, ...)
 Checks at compile time that LHS is less than or equal to RHS.
#define TTS_CONSTEXPR_GREATER_EQUAL(LHS, RHS, ...)
 Checks at compile time that LHS is greater than or equal to RHS.

Macro Definition Documentation

◆ TTS_BIT_EQUAL

#define TTS_BIT_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions have the same bits.

Compares with the bit_equal member of tts::comparison, a memcmp over the whole object unless the type specializes it.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of bitwise equality tests")
{
TTS_BIT_EQUAL(1.f, 0x3F800000);
TTS_BIT_EQUAL(1., 0x3FF0000000000000ULL);
// This test would cause the program to stop with a failure.
// TTS_BIT_EQUAL(12, 21, REQUIRED);
};

◆ TTS_BIT_NOT_EQUAL

#define TTS_BIT_NOT_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions have different bits.

Compares with the bit_equal member of tts::comparison, a memcmp over the whole object unless the type specializes it.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of bitwise inequality tests")
{
TTS_BIT_NOT_EQUAL(1.f, 0x3F80F700);
TTS_BIT_NOT_EQUAL(2., 0x3FF0000000000000ULL);
// This test would cause the program to stop with a failure.
// TTS_BIT_NOT_EQUAL(21, 21, REQUIRED);
};

◆ TTS_CONSTEXPR_EQUAL

#define TTS_CONSTEXPR_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks at compile time that two constant expressions are equal.

Compares with operator==, or with the custom comparison of the two types.

Evaluates the expression at compile time, so it must be a constant expression, or the test does not compile. Reports the check at run time with the others, as a pass or a failure.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of constexpr equality tests")
{
constexpr int a = 45;
};

◆ TTS_CONSTEXPR_GREATER

#define TTS_CONSTEXPR_GREATER ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks at compile time that LHS is greater than RHS.

Holds when LHS is neither less than nor equal to RHS. Compares with operator< and operator==, or with the custom comparison of the two types.

Evaluates the expression at compile time, so it must be a constant expression, or the test does not compile. Reports the check at run time with the others, as a pass or a failure.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of constexpr greater-than tests")
{
constexpr int a = 45;
constexpr int b = 4;
};

◆ TTS_CONSTEXPR_GREATER_EQUAL

#define TTS_CONSTEXPR_GREATER_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks at compile time that LHS is greater than or equal to RHS.

Holds when LHS is not less than RHS. Compares with operator<, or with the custom comparison of the two types.

Evaluates the expression at compile time, so it must be a constant expression, or the test does not compile. Reports the check at run time with the others, as a pass or a failure.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of constexpr less-or-equal-than tests")
{
constexpr int a = 45;
constexpr int b = 4;
};

◆ TTS_CONSTEXPR_LESS

#define TTS_CONSTEXPR_LESS ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks at compile time that LHS is less than RHS.

Compares with operator<, or with the custom comparison of the two types.

Evaluates the expression at compile time, so it must be a constant expression, or the test does not compile. Reports the check at run time with the others, as a pass or a failure.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of constexpr less-than tests")
{
constexpr int a = 4;
constexpr int b = 45;
};

◆ TTS_CONSTEXPR_LESS_EQUAL

#define TTS_CONSTEXPR_LESS_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks at compile time that LHS is less than or equal to RHS.

Compares with operator< and operator==, or with the custom comparison of the two types.

Evaluates the expression at compile time, so it must be a constant expression, or the test does not compile. Reports the check at run time with the others, as a pass or a failure.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of constexpr less-or-equal-than tests")
{
constexpr int a = 4;
constexpr int b = 45;
};

◆ TTS_CONSTEXPR_NOT_EQUAL

#define TTS_CONSTEXPR_NOT_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks at compile time that two constant expressions are not equal.

Compares with operator==, or with the custom comparison of the two types.

Evaluates the expression at compile time, so it must be a constant expression, or the test does not compile. Reports the check at run time with the others, as a pass or a failure.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("Check correctness of constexpr equality tests")
{
constexpr int a = 4;
constexpr int b = 45;
};

◆ TTS_EQUAL

#define TTS_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are equal.

Compares with operator==, or with the custom comparison of the two types.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of equality tests")
{
TTS_EQUAL(45, 45);
std::vector<float> a {1, 2, 3}, b {1, 2, 3};
TTS_EQUAL(a, b);
// This test would cause the program to stop with a failure.
// TTS_EQUAL(12, 21, REQUIRED);
};

◆ TTS_GREATER

#define TTS_GREATER ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that LHS is greater than RHS.

Holds when LHS is neither less than nor equal to RHS. Compares with operator< and operator==, or with the custom comparison of the two types.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of greater-than comparison tests")
{
TTS_GREATER(69, 42);
std::vector<float> a {13, 5}, b {2, 4, 6};
TTS_GREATER(a, b);
// This test will cause the program to stop with a failure
// TTS_GREATER(1., 10., REQUIRED);
};

◆ TTS_GREATER_EQUAL

#define TTS_GREATER_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that LHS is greater than or equal to RHS.

Holds when LHS is not less than RHS. Compares with operator<, or with the custom comparison of the two types.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of greater-equal comparison tests")
{
std::vector<float> a {12, 3}, b {7, 9, 11};
// This test would cause the program to stop with a failure
// TTS_GREATER_EQUAL(1., 10., REQUIRED);
};

◆ TTS_LESS

#define TTS_LESS ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that LHS is less than RHS.

Compares with operator<, or with the custom comparison of the two types.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of less-than comparison tests")
{
TTS_LESS(42., 69);
std::vector<float> a {1, 2, 3}, b {12, 3};
TTS_LESS(a, b);
// This test would cause the program to stop with a failure
// TTS_LESS(69, 42, REQUIRED);
};

◆ TTS_LESS_EQUAL

#define TTS_LESS_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that LHS is less than or equal to RHS.

Compares with operator< and operator==, or with the custom comparison of the two types.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of less-equal comparison tests")
{
TTS_LESS_EQUAL(42., 69);
TTS_LESS_EQUAL(69., 69);
std::vector<float> a {1, 2, 3}, b {7, 9};
// This test would cause the program to stop with a failure
// TTS_LESS_EQUAL(10., 1., REQUIRED);
};

◆ TTS_NOT_EQUAL

#define TTS_NOT_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are not equal.

Compares with operator==, or with the custom comparison of the two types.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of inequality tests")
{
TTS_NOT_EQUAL(42, 69);
std::vector<float> a {1, 2, 3}, b {7, 9};
// This test would cause the program to stop with a failure
// TTS_NOT_EQUAL('A', 65, REQUIRED);
};

◆ TTS_TYPED_EQUAL

#define TTS_TYPED_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are of the same type and that they are equal.

Behaves as TTS_EQUAL, and also fails when LHS and RHS differ in type.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of type checked equality tests")
{
TTS_TYPED_EQUAL(45, 45.f);
std::vector<float> a {1, 2, 3}, b {1, 2, 3};
};

◆ TTS_TYPED_GREATER

#define TTS_TYPED_GREATER ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are of the same type and that LHS is greater than RHS.

Behaves as TTS_GREATER, and also fails when LHS and RHS differ in type.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of type checked greater-than comparison tests")
{
TTS_TYPED_GREATER(69., 42ULL);
TTS_TYPED_GREATER(69., 42.);
std::vector<float> a {13, 5}, b {2, 4, 6};
};

◆ TTS_TYPED_GREATER_EQUAL

#define TTS_TYPED_GREATER_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are of the same type and that LHS is greater than or equal to RHS.

Behaves as TTS_GREATER_EQUAL, and also fails when LHS and RHS differ in type.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of type checked greater-equal comparison tests")
{
std::vector<float> a {12, 3}, b {7, 9, 11};
};

◆ TTS_TYPED_LESS

#define TTS_TYPED_LESS ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are of the same type and that LHS is less than RHS.

Behaves as TTS_LESS, and also fails when LHS and RHS differ in type.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of type checked less-than comparison tests")
{
TTS_TYPED_LESS(42., 69.);
TTS_TYPED_LESS(42., 69);
std::vector<float> a {1, 2, 3}, b {12, 3};
};

◆ TTS_TYPED_LESS_EQUAL

#define TTS_TYPED_LESS_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are of the same type and that LHS is less than or equal to RHS.

Behaves as TTS_LESS_EQUAL, and also fails when LHS and RHS differ in type.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of type checked less-equal comparison tests")
{
TTS_TYPED_LESS_EQUAL(42.f, 69LL);
TTS_TYPED_LESS_EQUAL(42.f, 69.f);
std::vector<float> a {1, 2, 3}, b {79, 11};
};

◆ TTS_TYPED_NOT_EQUAL

#define TTS_TYPED_NOT_EQUAL ( LHS,
RHS,
... )

#include <tts/test/relation.hpp>

Checks that two expressions are of the same type and that they are not equal.

Behaves as TTS_NOT_EQUAL, and also fails when LHS and RHS differ in type.

Parameters
LHS,RHSExpressions to compare.
...REQUIRED ends the run when the check fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
TTS_CASE("Check correctness of type checked non-equality tests")
{
std::vector<float> a {1, 2, 3}, b {7, 9};
};