2018-04-19 15:03:49 -04:00
|
|
|
|
2020-10-16 03:25:52 -04:00
|
|
|
#include <cstdlib>
|
2018-04-19 15:03:49 -04:00
|
|
|
#include <fstream>
|
2020-10-16 03:25:52 -04:00
|
|
|
#include <iterator>
|
2018-04-19 15:03:49 -04:00
|
|
|
#include <stdexcept>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include <test.hpp> // IWYU pragma: keep
|
|
|
|
|
|
|
|
std::string load_data(const std::string& filename) {
|
|
|
|
const char* tests_dir = std::getenv("TESTS_DIR");
|
|
|
|
if (tests_dir == nullptr) {
|
|
|
|
tests_dir = "test";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string fullname{tests_dir};
|
|
|
|
fullname += "/t/";
|
|
|
|
fullname += filename;
|
|
|
|
fullname += ".pbf";
|
|
|
|
|
|
|
|
std::ifstream stream{fullname, std::ios_base::in | std::ios_base::binary};
|
|
|
|
if (!stream.is_open()) {
|
|
|
|
throw std::runtime_error{"could not open: '" + filename + "'"};
|
|
|
|
}
|
|
|
|
std::string buffer{std::istreambuf_iterator<char>(stream.rdbuf()),
|
|
|
|
std::istreambuf_iterator<char>()};
|
|
|
|
stream.close();
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|