Wildmeshing Toolkit
test_component_output.cpp
Go to the documentation of this file.
1 #include <catch2/catch_test_macros.hpp>
2 #include <nlohmann/json.hpp>
5 #include <wmtk/components/utils/Paths.hpp>
6 
7 using namespace wmtk::components::utils;
8 
10 
11 const std::filesystem::path data_dir = WMTK_DATA_DIR;
12 
13 TEST_CASE("component_output", "[components][output]")
14 {
15  wmtk::io::Cache cache("wmtk_cache", ".");
16 
17  const std::filesystem::path input_file = data_dir / "armadillo.msh";
18  json input_component_json = {
19  {"type", "input"},
20  {"name", "input_mesh"},
21  {"cell_dimension", 2},
22  {"file", input_file.string()},
23  {"ignore_z", false},
24  {"tetrahedron_attributes", json::array()}};
25 
26  wmtk::components::input(Paths(), input_component_json, cache);
27 
28  SECTION("should pass")
29  {
30  json component_json = R"({
31  "input": "input_mesh",
32  "attributes": {"position": "vertices"},
33  "file": "bunny"
34  })"_json;
35 
36  CHECK_NOTHROW(wmtk::components::output(Paths(), component_json, cache));
37  }
38 
39  SECTION("should throw")
40  {
41  json component_json = R"({
42  "input": "input_mesh",
43  "attributes": {"position": "vertices"},
44  "file": "unknown file ending.abcdef"
45  })"_json;
46 
47  CHECK_THROWS(wmtk::components::output(Paths(), component_json, cache));
48  }
49 }
std::shared_ptr< Mesh > input(const std::filesystem::path &file, const bool ignore_z_if_zero, const std::vector< std::string > &tetrahedron_attributes)
Definition: input.cpp:12
const std::filesystem::path data_dir
TEST_CASE("component_output", "[components][output]")
nlohmann::json json
nlohmann::json json
Definition: input.cpp:9