Deep Learning Visualizer
Interactive visualization of basic applications of deep learning
Loading...
Searching...
No Matches
test_helpers.h File Reference

Utilities shared by the unit tests. More...

#include <catch_amalgamated.h>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <string>
#include <string_view>
#include <vector>

Go to the source code of this file.

Classes

class  test_helpers::temp_file
 A scratch file in the system temporary directory which is removed once the test finishes, whether it passed or not. More...
 

Functions

std::vector< std::uint8_t > test_helpers::idx_header (std::uint8_t data_type, const std::vector< std::int64_t > &dimensions)
 Builds the header of an IDX file, which is a null magic number, a one byte data type, a one byte dimension count, and then the big endian size of each dimension.
 
Catch::Matchers::WithinAbsMatcher test_helpers::within_abs (float target, double epsilon=1e-5)
 Matches a float against a target within an absolute tolerance.
 

Detailed Description

Utilities shared by the unit tests.

Function Documentation

◆ idx_header()

std::vector< std::uint8_t > test_helpers::idx_header ( std::uint8_t  data_type,
const std::vector< std::int64_t > &  dimensions 
)
inline

Builds the header of an IDX file, which is a null magic number, a one byte data type, a one byte dimension count, and then the big endian size of each dimension.

Parameters
data_typeThe type of the stored data, such as 0x08 for a byte.
dimensionsThe size of each dimension of the data.
Returns
The bytes which precede the data in an IDX file.

◆ within_abs()

Catch::Matchers::WithinAbsMatcher test_helpers::within_abs ( float  target,
double  epsilon = 1e-5 
)
inline

Matches a float against a target within an absolute tolerance.

Parameters
targetThe expected value.
epsilonThe largest accepted absolute difference.
Returns
A matcher for use with CHECK_THAT and REQUIRE_THAT.