Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::ValueChecker Class Reference

Checking the validity of certain values. More...

#include <arcane/utils/ValueChecker.h>

Public Member Functions

 ValueChecker (const TraceInfo &ti)
template<typename T1, typename T2, typename X = std::is_convertible<T2, T1>>
void areEqual (const T1 &value, const T2 &expected_value, const String &message)
template<typename T1, typename T2, typename ValueType = typename T1::value_type, typename X1 = std::is_convertible<T1, Span<const ValueType>>, typename X2 = std::is_convertible<T1, Span<const ValueType>>>
void areEqualArray (const T1 &x_values, const T2 &x_expected_values, const String &message)
 Checks that the two arrays values and expected_values have the same values.
template<typename T>
void areEqualArray (Span2< const T > values, Span2< const T > expected_values, const String &message)
 Checks that the two 2D arrays values and expected_values have the same values.
template<typename T>
void areEqualArray (SmallSpan2< T > values, SmallSpan2< T > expected_values, const String &message)
 Checks that the two arrays values and expected_values have the same values.
void throwIfError ()
 Throws an exception if nbError()!=0.
void setThrowOnError (bool v)
 Indicates whether an exception is thrown in case of an error.
bool throwOnError () const
 Indicates whether an exception is thrown in case of an error.
Integer nbError () const
 Number of errors.

Detailed Description

Checking the validity of certain values.

This class provides a set of methods to check that values conform to a reference.

By default, if a value is different from its reference, an exception is thrown. It is possible to change this behavior by setting setThrowIfError() to false. In this case, it is possible to manually throw the exception by calling throwIfError().

Definition at line 41 of file ValueChecker.h.

Constructor & Destructor Documentation

◆ ValueChecker()

Arcane::ValueChecker::ValueChecker ( const TraceInfo & ti)
inline

Definition at line 45 of file ValueChecker.h.

Member Function Documentation

◆ areEqual()

template<typename T1, typename T2, typename X = std::is_convertible<T2, T1>>
void Arcane::ValueChecker::areEqual ( const T1 & value,
const T2 & expected_value,
const String & message )
inline

Checks that value and expected_value have the same values.

Definition at line 57 of file ValueChecker.h.

◆ areEqualArray() [1/3]

template<typename T1, typename T2, typename ValueType = typename T1::value_type, typename X1 = std::is_convertible<T1, Span<const ValueType>>, typename X2 = std::is_convertible<T1, Span<const ValueType>>>
void Arcane::ValueChecker::areEqualArray ( const T1 & x_values,
const T2 & x_expected_values,
const String & message )
inline

Checks that the two arrays values and expected_values have the same values.

Definition at line 72 of file ValueChecker.h.

References Arcane::SpanImpl< T, SizeType, Extent >::size().

Referenced by areEqualArray(), and areEqualArray().

◆ areEqualArray() [2/3]

template<typename T>
void Arcane::ValueChecker::areEqualArray ( SmallSpan2< T > values,
SmallSpan2< T > expected_values,
const String & message )
inline

Checks that the two arrays values and expected_values have the same values.

Definition at line 124 of file ValueChecker.h.

References areEqualArray().

◆ areEqualArray() [3/3]

template<typename T>
void Arcane::ValueChecker::areEqualArray ( Span2< const T > values,
Span2< const T > expected_values,
const String & message )
inline

Checks that the two 2D arrays values and expected_values have the same values.

Definition at line 102 of file ValueChecker.h.

References areEqualArray(), and Arcane::Span2Impl< T, SizeType, Extent1, Extent2 >::dim1Size().

◆ nbError()

Integer Arcane::ValueChecker::nbError ( ) const
inline

Number of errors.

Definition at line 145 of file ValueChecker.h.

◆ setThrowOnError()

void Arcane::ValueChecker::setThrowOnError ( bool v)
inline

Indicates whether an exception is thrown in case of an error.

Definition at line 136 of file ValueChecker.h.

◆ throwIfError()

void Arcane::ValueChecker::throwIfError ( )

Throws an exception if nbError()!=0.

Definition at line 44 of file ValueChecker.cc.

◆ throwOnError()

bool Arcane::ValueChecker::throwOnError ( ) const
inline

Indicates whether an exception is thrown in case of an error.

Definition at line 142 of file ValueChecker.h.


The documentation for this class was generated from the following files: