26 lines
1.1 KiB
C++
26 lines
1.1 KiB
C++
#pragma once
|
|
// The one accessor over the frozen package-compat corpus (tests/fixtures/package_compat).
|
|
// REASAMPLER_PACKAGE_FIXTURE_DIR is a compile-time absolute path defined by each
|
|
// consuming test target: the corpus is source-tree data, and a test's working directory
|
|
// under ctest differs between single- and multi-config generators, so no relative
|
|
// spelling reaches it from both.
|
|
//
|
|
// Every caller must check the returned size: a fixture that failed to open reads as an
|
|
// empty buffer, which a "this must be Malformed" assertion would otherwise pass.
|
|
|
|
#include <cstdint>
|
|
#include <fstream>
|
|
#include <iterator>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
inline std::string packageFixturePath(const std::string& name) {
|
|
return std::string(REASAMPLER_PACKAGE_FIXTURE_DIR) + "/" + name;
|
|
}
|
|
|
|
inline std::vector<std::uint8_t> packageFixtureBytes(const std::string& name) {
|
|
std::ifstream f(packageFixturePath(name), std::ios::binary);
|
|
return std::vector<std::uint8_t>(std::istreambuf_iterator<char>(f),
|
|
std::istreambuf_iterator<char>());
|
|
}
|