11 #include <gtest/gtest.h>
13 #ifndef UTIL_UNITTESTS_TEXTDATA_H
14 #define UTIL_UNITTESTS_TEXTDATA_H 1
32 template <
typename EXPECTED_STREAM,
typename ACTUAL_STREAM>
35 std::string actual_line;
36 std::string expected_line;
37 while (std::getline(actual, actual_line), !actual.eof()) {
38 std::getline(expected, expected_line);
40 FAIL() <<
"Redundant line in actual output: " << actual_line;
43 if (actual.bad() || actual.fail() ||
44 expected.bad() || expected.fail()) {
45 throw std::runtime_error(
"Unexpected error in data streams");
47 EXPECT_EQ(expected_line, actual_line);
49 while (std::getline(expected, expected_line), !expected.eof()) {
50 ADD_FAILURE() <<
"Missing line in actual output: " << expected_line;
61 template <
typename EXPECTED_STREAM>
63 matchTextData(EXPECTED_STREAM& expected,
const std::string& actual_text) {
64 std::istringstream iss(actual_text);
69 template <
typename ACTUAL_STREAM>
71 matchTextData(
const std::string& expected_text, ACTUAL_STREAM& actual) {
72 std::istringstream iss(expected_text);
80 const std::string& actual_text)
82 std::istringstream expected_is(expected_text);
83 std::istringstream actual_is(actual_text);
91 #endif // UTIL_UNITTESTS_TEXTDATA_H
Defines the logger used by the top-level component of kea-dhcp-ddns.
void matchTextData(EXPECTED_STREAM &expected, ACTUAL_STREAM &actual)
Line-by-line text comparison.