update headless testing to be configurable

This commit is contained in:
Konstantin Käfer
2014-07-08 14:38:49 -07:00
parent 4c75c696b3
commit af6091db5a
18 changed files with 125 additions and 39 deletions

View File

@@ -1,8 +1,14 @@
#include <llmr/util/io.hpp>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
void llmr::util::write_file(const std::string &filename, const std::string &data) {
namespace llmr {
namespace util {
void write_file(const std::string &filename, const std::string &data) {
FILE *fd = fopen(filename.c_str(), "wb");
if (fd) {
fwrite(data.data(), sizeof(std::string::value_type), data.size(), fd);
@@ -11,3 +17,17 @@ void llmr::util::write_file(const std::string &filename, const std::string &data
fprintf(stderr, "Failed to open file\n");
}
}
std::string read_file(const std::string &filename) {
std::ifstream file(filename);
if (file.good()) {
std::stringstream data;
data << file.rdbuf();
return data.str();
} else {
throw std::runtime_error("Cannot read file " + filename);
}
}
}
}