45 lines
939 B
C++
45 lines
939 B
C++
#include "fesa/io/Hdf5ResultWriter.hpp"
|
|
|
|
#include <stdexcept>
|
|
|
|
namespace {
|
|
|
|
int require(bool condition) {
|
|
return condition ? 0 : 1;
|
|
}
|
|
|
|
template <typename Exception, typename Function>
|
|
int require_throws(Function&& function) {
|
|
try {
|
|
function();
|
|
} catch (const Exception&) {
|
|
return 0;
|
|
} catch (...) {
|
|
return 1;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int construct_writer_preserves_output_path() {
|
|
const fesa::io::Hdf5ResultWriter writer{"results.h5"};
|
|
return require(writer.filePath() == "results.h5");
|
|
}
|
|
|
|
int empty_output_path_throws() {
|
|
return require_throws<std::invalid_argument>([]() {
|
|
(void)fesa::io::Hdf5ResultWriter{""};
|
|
});
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
if (const int result = construct_writer_preserves_output_path(); result != 0) {
|
|
return result;
|
|
}
|
|
if (const int result = empty_output_path_throws(); result != 0) {
|
|
return result;
|
|
}
|
|
return 0;
|
|
}
|