tests
: attempt to find assets for tests run from build subfolder
This commit is contained in:
parent
bc3e0c0830
commit
a072f30a8d
2 changed files with 8 additions and 1 deletions
|
@ -63,6 +63,10 @@ static std::vector<std::string> find_files(const std::string & folder, const std
|
|||
static std::string read_file(const std::string &path) {
|
||||
std::ifstream fs(path, std::ios_base::binary);
|
||||
if (!fs.is_open()) {
|
||||
fs = std::ifstream("../" + path, std::ios_base::binary);
|
||||
if (!fs.is_open()) {
|
||||
throw std::runtime_error("Failed to open file: " + path);
|
||||
}
|
||||
throw std::runtime_error("Failed to open file: " + path);
|
||||
}
|
||||
fs.seekg(0, std::ios_base::end);
|
||||
|
|
|
@ -20,9 +20,12 @@ static void assert_equals(const std::string & expected, const std::string & actu
|
|||
|
||||
static std::string read_file(const std::string &path) {
|
||||
std::ifstream fs(path, std::ios_base::binary);
|
||||
if (!fs.is_open()) {
|
||||
fs = std::ifstream("../" + path, std::ios_base::binary);
|
||||
if (!fs.is_open()) {
|
||||
throw std::runtime_error("Failed to open file: " + path);
|
||||
}
|
||||
}
|
||||
fs.seekg(0, std::ios_base::end);
|
||||
auto size = fs.tellg();
|
||||
fs.seekg(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue