Kea  2.1.7-git
isc::test Namespace Reference

Classes

struct  LibLoadTest
 Test fixture for testing loading and unloading of hook libraries. More...
 
class  MultiThreadingTest
 A RAII class which disables the multi threading on exit of scope. More...
 
class  Sandbox
 A Sandbox class that provides access to unit test unique temporary folder. More...
 
class  ThreadedTest
 Base class for tests requiring threads. More...
 

Functions

std::string decommentJSONfile (const std::string &input_file)
 
bool fileExists (const std::string &file_path)
 Checks if specified file exists. More...
 
std::string generateDiff (std::string left, std::string right)
 Return the difference between two strings. More...
 
ElementPtr moveComments (isc::data::ElementPtr element)
 Move comment entries to user-context. More...
 
ConstElementPtr moveComments (isc::data::ConstElementPtr element)
 Move comment entries to user-context (const variant) More...
 
std::string readFile (const std::string &file_path)
 Reads contents of the specified file. More...
 
template<typename Cfg >
void runToElementTest (const std::string &expected, const Cfg &cfg)
 Run a test using toElement() method with a string. More...
 
template<typename Cfg >
void runToElementTest (isc::data::ConstElementPtr expected, const Cfg &cfg)
 Run a test using toElement() method with an Element. More...
 

Variables

comments from the input file and writes its content *to another file The comments are replaced with so the original *token locations should remain unaffected This is rather naive but it s probably sufficient for testing It won t be able *to pick any trickier cases
 
comments from the input file and writes its content *to another file The comments are replaced with so the original *token locations should remain unaffected This is rather naive * implementation
 
comments from the input file and writes its content *to another file The comments are replaced with spaces
 Removes comments from a JSON file. More...
 

Function Documentation

◆ decommentJSONfile()

comments from the input file and writes its content *to another file The comments are replaced with so the original *token locations should remain unaffected This is rather naive but it s probably sufficient for testing It won t be able *to pick any trickier like *comments etc at the exception of **param input_file file to be stripped of comments *return filename of a new file that has comments stripped from it *throw BadValue if the input file cannot be opened *std::string isc::test::decommentJSONfile ( const std::string &  input_file)

Definition at line 41 of file io_utils.cc.

References isc_throw.

◆ fileExists()

bool isc::test::fileExists ( const std::string &  file_path)

Checks if specified file exists.

Parameters
file_pathPath to a file.
Returns
true if the file exists, false otherwise.

Definition at line 19 of file io_utils.cc.

◆ generateDiff()

std::string isc::test::generateDiff ( std::string  left,
std::string  right 
)

Return the difference between two strings.

Use the gtest >= 1.8.0 tool which builds the difference between two vectors of lines.

Parameters
leftleft string
rightright string
Returns
the unified diff between left and right

Definition at line 28 of file test_to_element.cc.

Referenced by runToElementTest().

◆ moveComments() [1/2]

isc::data::ElementPtr isc::test::moveComments ( isc::data::ElementPtr  element)

Move comment entries to user-context.

Process an element looking for comment entries in maps and moving them to user-context entries. As the common case is no comment and this routine tries to maximize sharing the standard behavior is just to return the argument unchanged.

Parameters
element
Returns
a processed copy of element or unmodified element

Definition at line 126 of file user_context_utils.cc.

◆ moveComments() [2/2]

isc::data::ConstElementPtr isc::test::moveComments ( isc::data::ConstElementPtr  element)

Move comment entries to user-context (const variant)

Parameters
element
Returns
a processed copy of element or unmodified element

Definition at line 131 of file user_context_utils.cc.

◆ readFile()

std::string isc::test::readFile ( const std::string &  file_path)

Reads contents of the specified file.

Parameters
file_pathPath to a file.
Returns
File contents.

Definition at line 24 of file io_utils.cc.

◆ runToElementTest() [1/2]

template<typename Cfg >
void isc::test::runToElementTest ( const std::string &  expected,
const Cfg &  cfg 
)

Run a test using toElement() method with a string.

Template Parameters
Cfgthe class implementing the toElement() method
Parameters
expectedthe expected textual value
cfgan instance of the Cfg class

Definition at line 41 of file test_to_element.h.

References generateDiff(), isc::data::isEquivalent(), and isc::data::prettyPrint().

+ Here is the call graph for this function:

◆ runToElementTest() [2/2]

template<typename Cfg >
void isc::test::runToElementTest ( isc::data::ConstElementPtr  expected,
const Cfg &  cfg 
)

Run a test using toElement() method with an Element.

Template Parameters
Cfgthe class implementing the toElement() method
Parameters
expectedthe expected element value
cfgan instance of the Cfg class

Definition at line 69 of file test_to_element.h.

References generateDiff(), isc::data::isEquivalent(), and isc::data::prettyPrint().

+ Here is the call graph for this function:

Variable Documentation

◆ cases

comments from the input file and writes its content* to another file The comments are replaced with so the original* token locations should remain unaffected This is rather naive but it s probably sufficient for testing It won t be able* to pick any trickier isc::test::cases

Definition at line 31 of file io_utils.h.

◆ implementation

comments from the input file and writes its content* to another file The comments are replaced with so the original* token locations should remain unaffected This is rather naive* isc::test::implementation

Definition at line 31 of file io_utils.h.

◆ spaces

comments from the input file and writes its content* to another file The comments are replaced with isc::test::spaces

Removes comments from a JSON file.

Removes //, # and /*

Definition at line 31 of file io_utils.h.