test/test_util.cc
author Roker <roker@pep-project.org>
Mon, 13 Mar 2017 20:20:10 +0100
branchENGINE-189
changeset 1656 ea7d229bed3f
child 1812 925ad845e3ec
permissions -rw-r--r--
add test_util for common test functions (only slurp() at the moment)
     1 #include "pEpEngine_test.h"
     2 #include <fstream>
     3 #include <sstream>
     4 #include <stdexcept>
     5 
     6 std::string slurp(const std::string& filename)
     7 {
     8 	std::ifstream input(filename.c_str());
     9 	if(!input)
    10 	{
    11 		throw std::runtime_error("Cannot read file \"" + filename + "\"! ");
    12 	}
    13 	
    14 	std::stringstream sstr;
    15 	sstr << input.rdbuf();
    16 	return sstr.str();
    17 }