Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better error handling of test #935

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions lib/resdata/tests/rd_grid_dx_dy_dz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,33 @@
#include <math.h>

#include <string>
#include <filesystem>
#include <iostream>

#include <ert/util/test_util.hpp>
#include <ert/util/util.h>

#include <resdata/rd_grid.hpp>
#include <resdata/rd_file.hpp>

namespace fs = std::filesystem;

double err(double a, double b) { return (a - b) / a; }

void test_dxdydz(const std::string &grid_fname, const std::string &init_fname) {
double eps_x = 1e-4;
double eps_y = 1e-4;
double eps_z = 1e-3;
rd_grid_type *grid = rd_grid_alloc(grid_fname.c_str());
if (grid == NULL) {
std::cerr << "Could not open " << grid_fname << std::endl;
exit(-1);
}
rd_file_type *init_file = rd_file_open(init_fname.c_str(), 0);
if (init_file == NULL) {
std::cerr << "Could not open " << init_fname << std::endl;
exit(-1);
}
rd_kw_type *dx = rd_file_iget_named_kw(init_file, "DX", 0);
rd_kw_type *dy = rd_file_iget_named_kw(init_file, "DY", 0);
rd_kw_type *dz = rd_file_iget_named_kw(init_file, "DZ", 0);
Expand Down Expand Up @@ -46,9 +58,19 @@ void test_dxdydz(const std::string &grid_fname, const std::string &init_fname) {
}

int main(int argc, char **argv) {
if (argc < 2) {
std::cerr << "Must give case as input" << std::endl;
exit(-1);
}
const std::string rd_case = argv[1];
std::string grid_file = rd_case + ".EGRID";
std::string init_file = rd_case + ".INIT";
fs::path grid_file = rd_case + ".EGRID";
fs::path init_file = rd_case + ".INIT";

if (!fs::exists(grid_file) || !fs::exists(init_file)) {
std::cerr << "Given case " << rd_case << " without grid or init"
<< std::endl;
exit(-1);
}

test_dxdydz(grid_file, init_file);

Expand Down
Loading