TTS v3.0.0
The Tiny Test System
 
Loading...
Searching...
No Matches
tts::limits_set< T > Struct Template Reference

Defines a set of limits for a type T. More...

Detailed Description

template<typename T>
struct tts::limits_set< T >

Defines a set of limits for a type T.

This structure provides a set of limits and special values for the type T that can be used for generating test data that covers edge cases and special values. The actual limits provided depend on the type T and its base type.

The provided limits include:

  • valmax: The maximum representable value of the base type.
  • valmin: The minimum representable value of the base type.
  • zero: The value representing zero.
  • one: The value representing one.

For floating-point types, additional limits include:

  • nan: Not-a-Number value.
  • inf: Positive infinity.
  • minf: Negative infinity.
  • maxflint: The largest integer value that can be exactly represented in the type.
  • mindenormal: The smallest positive subnormal value.
  • smallestposval: The smallest positive normal value.
  • mzero: Negative zero.
  • mone: The value representing negative one.

This class can be specialized for user-defined types to provide custom limits.

Examples

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
TTS_CASE("limits generator example")
{
// Create a limits generator for float
auto l = tts::limits(tts::type<float> {});
// Basic sanity checks
TTS_EXPECT(l.nan != l.nan);
TTS_EQUAL(l.inf, std::numeric_limits<float>::infinity());
TTS_EQUAL(l.valmax, std::numeric_limits<float>::max());
TTS_EQUAL(l.valmin, std::numeric_limits<float>::lowest());
TTS_EQUAL(l.maxflint, static_cast<float>(1u << std::numeric_limits<float>::digits));
};
#define TTS_EXPECT(EXPR,...)
Check if a given expression evaluates to true.
Definition basic.hpp:43
#define TTS_EQUAL(LHS, RHS,...)
Performs equality comparison between two expressions.
Definition relation.hpp:134
#define TTS_CASE(ID)
Introduces a new test scenario and registers it into the current test driver.
Definition case.hpp:145
auto constexpr typename_
Evaluates to an object containing the name of the type T in readable form.
Definition typename.hpp:153
Encapsulates a single type into a reusable type object.
Definition types.hpp:112
Template Parameters
TType for which to provide limits for.

Related Symbols

(Note that these are not member symbols.)

template<typename T >
auto limits (tts::type< T >)
 Provides a set of limits for the type T.