OTest2
A C++ testing framework
Public Member Functions | Static Public Member Functions | List of all members
OTest2::TestMarkHash Class Reference

A simple generator of a testmark hash. More...

#include <testmarkhash.h>

Public Member Functions

 TestMarkHash ()
 Ctor. More...
 
 TestMarkHash (TestMarkHash &&other_) noexcept
 Move ctor. More...
 
 ~TestMarkHash ()
 Dtor. More...
 
 TestMarkHash (const TestMarkHash &)=delete
 
TestMarkHashoperator= (const TestMarkHash &)=delete
 
void addData (const std::uint8_t *data_, std::size_t size_)
 Append piece of data. More...
 
void addTerminator ()
 Append a terminataor character into the hash. More...
 
void addHashCode (TestMarkHashCode code_)
 Append a hash code of another testmark. More...
 
void addString (const char *string_)
 Append a string literal. More...
 
TestMarkHashCode getHashCode () const noexcept
 Get currently computed hash code. More...
 
void addBasicType (const char *type_name_, const std::uint8_t *data_, std::size_t size_)
 Add hash for a value of a basic type. More...
 
void addBasicType (const char *type_name_, const std::string &value_)
 Add hash for a string value of a basic type. More...
 

Static Public Member Functions

template<typename Type_ >
static TestMarkHashCode hashBasicType (const char *type_name_, Type_ value_)
 
static TestMarkHashCode hashBasicType (const char *type_name_, const std::string &value_)
 

Detailed Description

A simple generator of a testmark hash.

This class computes a hash value for a test mark tree. It's an attempt to get a simple value to compare the whole subtree.

The used FNV-1 function may be a wrong choice. However, I don't need a strong hash function - a collision will cause no problem, just printing of a false test-mark difference.

Definition at line 40 of file testmarkhash.h.

Constructor & Destructor Documentation

◆ TestMarkHash() [1/3]

OTest2::TestMarkHash::TestMarkHash ( )

Ctor.

Definition at line 26 of file testmarkhash.cpp.

◆ TestMarkHash() [2/3]

OTest2::TestMarkHash::TestMarkHash ( TestMarkHash &&  other_)
noexcept

Move ctor.

Definition at line 31 of file testmarkhash.cpp.

◆ ~TestMarkHash()

OTest2::TestMarkHash::~TestMarkHash ( )

Dtor.

Definition at line 37 of file testmarkhash.cpp.

◆ TestMarkHash() [3/3]

OTest2::TestMarkHash::TestMarkHash ( const TestMarkHash )
delete

Member Function Documentation

◆ addBasicType() [1/2]

void OTest2::TestMarkHash::addBasicType ( const char *  type_name_,
const std::string &  value_ 
)

Add hash for a string value of a basic type.

Parameters
type_name_Name of the type
value_The value

Definition at line 81 of file testmarkhash.cpp.

◆ addBasicType() [2/2]

void OTest2::TestMarkHash::addBasicType ( const char *  type_name_,
const std::uint8_t *  data_,
std::size_t  size_ 
)

Add hash for a value of a basic type.

Parameters
type_name_Name of the type
data_Binary form of data
size_Size of data

Definition at line 72 of file testmarkhash.cpp.

◆ addData()

void OTest2::TestMarkHash::addData ( const std::uint8_t *  data_,
std::size_t  size_ 
)

Append piece of data.

Parameters
data_Data
size_Length of data

Definition at line 41 of file testmarkhash.cpp.

◆ addHashCode()

void OTest2::TestMarkHash::addHashCode ( TestMarkHashCode  code_)

Append a hash code of another testmark.

Definition at line 56 of file testmarkhash.cpp.

◆ addString()

void OTest2::TestMarkHash::addString ( const char *  string_)

Append a string literal.

Definition at line 61 of file testmarkhash.cpp.

◆ addTerminator()

void OTest2::TestMarkHash::addTerminator ( )

Append a terminataor character into the hash.

Definition at line 51 of file testmarkhash.cpp.

◆ getHashCode()

TestMarkHashCode OTest2::TestMarkHash::getHashCode ( ) const
noexcept

Get currently computed hash code.

Definition at line 68 of file testmarkhash.cpp.

◆ hashBasicType() [1/2]

TestMarkHashCode OTest2::TestMarkHash::hashBasicType ( const char *  type_name_,
const std::string &  value_ 
)
static

Definition at line 91 of file testmarkhash.cpp.

◆ hashBasicType() [2/2]

template<typename Type_ >
static TestMarkHashCode OTest2::TestMarkHash::hashBasicType ( const char *  type_name_,
Type_  value_ 
)
inlinestatic

Definition at line 122 of file testmarkhash.h.

◆ operator=()

TestMarkHash& OTest2::TestMarkHash::operator= ( const TestMarkHash )
delete

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