TTS v3.0.0
The Tiny Test System
Loading...
Searching...
No Matches
Sequence Tests Macros

Macros for performing sequence-wide checks. More...

Macros

#define TTS_ALL_ABSOLUTE_EQUAL(L, R, N, ...)
 Checks if all elements of two sequences are within a given absolute distance and that their sizes are equal.
#define TTS_ALL_EQUAL(L, R, ...)
 Checks if all elements of two sequences are all equal and that their sizes are equal.
#define TTS_ALL_IEEE_EQUAL(L, R, ...)
 Checks if all elements of two sequences are within 0 ULP and that their sizes are equal.
#define TTS_ALL_RELATIVE_EQUAL(L, R, N, ...)
 Checks if all elements of two sequences are within a given relative percentage and that their sizes are equal.
#define TTS_ALL_ULP_EQUAL(L, R, N, ...)
 Checks if all elements of two sequences are within a given ULP distance and that their sizes are equal.

Macro Definition Documentation

◆ TTS_ALL_ABSOLUTE_EQUAL

#define TTS_ALL_ABSOLUTE_EQUAL ( L,
R,
N,
... )

#include <tts/test/sequence.hpp>

Checks if all elements of two sequences are within a given absolute distance and that their sizes are equal.

This comparison is performed by using the proper tts::absolute_check overload.

Parameters
L,RSequences to compare.
NMaximum absolute distance accepted between L and R.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
#include <list>
TTS_CASE("Absolute distance over sequences")
{
std::vector v {1.f, 2.f, 3.f, -1.f};
std::list w {1.f, 7.f, 3.f, -5.f};
};

◆ TTS_ALL_EQUAL

#define TTS_ALL_EQUAL ( L,
R,
... )

#include <tts/test/sequence.hpp>

Checks if all elements of two sequences are all equal and that their sizes are equal.

This comparison is performed by using the proper tts::absolute_check overload.

Parameters
L,RSequences to compare.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
#include <list>
TTS_CASE("Equality over sequences")
{
std::vector v {1.f, 2.f, 3.f, -5.f};
std::list w {1.f, 2.f, 3.f, -5.f};
};

◆ TTS_ALL_IEEE_EQUAL

#define TTS_ALL_IEEE_EQUAL ( L,
R,
... )

#include <tts/test/sequence.hpp>

Checks if all elements of two sequences are within 0 ULP and that their sizes are equal.

This also allow for infinites and NaNs to be compared equal if both values are the same infinites or are both $NaN$. This comparison is performed by using the proper tts::ulp_check overload.

Parameters
L,RSequences to compare.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
#include <list>
TTS_CASE("IEEE distance over sequences")
{
float x = std::numeric_limits<float>::quiet_NaN();
std::vector v {1.f, 2.f, 3.f, x};
std::list w {1.f, 2.f, 3.f, x};
};

◆ TTS_ALL_RELATIVE_EQUAL

#define TTS_ALL_RELATIVE_EQUAL ( L,
R,
N,
... )

#include <tts/test/sequence.hpp>

Checks if all elements of two sequences are within a given relative percentage and that their sizes are equal.

This comparison is performed by using the proper tts::relative_check overload.

Parameters
L,RSequences to compare.
NMaximum relative percentage accepted between L and R.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
#include <list>
TTS_CASE("Relative distance over sequences")
{
std::vector v {1.f, 2.f, 3.f, -5.f};
std::list w {1.f, 2.f, 3.1f, -5.f};
};

◆ TTS_ALL_ULP_EQUAL

#define TTS_ALL_ULP_EQUAL ( L,
R,
N,
... )

#include <tts/test/sequence.hpp>

Checks if all elements of two sequences are within a given ULP distance and that their sizes are equal.

This comparison is performed by using the proper tts::ulp_check overload.

Parameters
L,RSequences to compare.
NMaximum ULPs accepted between L and R.
...Optional tag. If equals to REQUIRED, this test will stop the program if it fails.

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <vector>
#include <list>
TTS_CASE("ULP distance over sequences")
{
std::vector v {1.f, 2.f, 3.f, -5.f};
std::list w {1.f + 1e-7f, 2.f, 3.f, -5.f};
TTS_ALL_ULP_EQUAL(v, w, 0.5);
};