Leosac  0.8.0
Open Source Access Control
Leosac::Test::Helper Namespace Reference

Unit testing utility class that helps writing test. More...

Classes

class  FakeGPIO
 A test helper class that emulate a GPIO pin. More...
 
class  FakeWiegandReader
 A test helper that fake a WiegandReader (it read command on a socket and send OK) More...
 
class  TestHelper
 Base class for test fixtures, it defines a ZMQ context, a BUS and a sub socket connect to the bus. More...
 

Functions

template<typename ModuleType >
bool test_run_module (zmqpp::context *ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg)
 Helper function that create an object of type ModuleType (using conventional parameter) and run it. More...
 
bool bus_read_extract (zmqpp::message *)
 Part of the bus_read() stuff. More...
 
template<typename... Content>
bool bus_read_extract (zmqpp::message *m, const char *first_arg, Content... content)
 Frame extraction method specialized (thanks to overloading) for const char * More...
 
template<typename T , typename... Content>
std::enable_if<!std::is_same< const char *, T >::value, bool >::type bus_read_extract (zmqpp::message *m, T first_arg, Content... content)
 Default frame extraction function. More...
 
template<typename... Content>
bool bus_read (zmqpp::socket &sub, Content... content)
 Make a blocking read on the bus, return true if content match the message. More...
 

Detailed Description

Unit testing utility class that helps writing test.

This namespace provide wrapper around google-test fixture test that help setup module for testing.

Function to read from application bus are also present here. Basically, anything that help write test should be here.

Function Documentation

◆ bus_read()

template<typename... Content>
bool Leosac::Test::Helper::bus_read ( zmqpp::socket &  sub,
Content...  content 
)

Make a blocking read on the bus, return true if content match the message.

false otherwise.

Definition at line 103 of file TestHelper.hpp.

◆ bus_read_extract() [1/3]

bool Leosac::Test::Helper::bus_read_extract ( zmqpp::message *  )

Part of the bus_read() stuff.

Definition at line 59 of file TestHelper.hpp.

◆ bus_read_extract() [2/3]

template<typename... Content>
bool Leosac::Test::Helper::bus_read_extract ( zmqpp::message *  m,
const char *  first_arg,
Content...  content 
)

Frame extraction method specialized (thanks to overloading) for const char *

Definition at line 88 of file TestHelper.hpp.

◆ bus_read_extract() [3/3]

template<typename T , typename... Content>
std::enable_if<!std::is_same<const char *, T>::value, bool>::type Leosac::Test::Helper::bus_read_extract ( zmqpp::message *  m,
first_arg,
Content...  content 
)

Default frame extraction function.

Disabled for const char *.

Definition at line 74 of file TestHelper.hpp.

◆ test_run_module()

template<typename ModuleType >
bool Leosac::Test::Helper::test_run_module ( zmqpp::context *  ctx,
zmqpp::socket *  pipe,
const boost::property_tree::ptree &  cfg 
)

Helper function that create an object of type ModuleType (using conventional parameter) and run it.

This runs in "module"'s thread.

Definition at line 42 of file TestHelper.hpp.