move utils
diff --git a/bench/run.cpp b/bench/run.cpp index 328d7fb..ab61b6b 100644 --- a/bench/run.cpp +++ b/bench/run.cpp
@@ -1,22 +1,24 @@ #include <benchmark/benchmark.h> #include <string> #include <delaunator.hpp> -#include "../test/test_utils.hpp" +#include "../examples/utils.hpp" -static void BM_simple(benchmark::State& state) // NOLINT google-runtime-references -{ - std::string points_str = test_utils::read_file("./test/test-files/osm-nodes-45331-epsg-3857.geojson"); - std::vector<double> coords = test_utils::get_geo_json_points(points_str); - - while (state.KeepRunning()) +namespace { + void BM_simple(benchmark::State& state) { - delaunator::Delaunator delaunator(coords); + std::string points_str = utils::read_file("./test/test-files/osm-nodes-45331-epsg-3857.geojson"); + std::vector<double> coords = utils::get_geo_json_points(points_str); + + while (state.KeepRunning()) + { + delaunator::Delaunator delaunator(coords); + } } } int main(int argc, char* argv[]) { - benchmark::RegisterBenchmark("BM_simple", BM_simple); // NOLINT clang-analyzer-cplusplus.NewDeleteLeaks + benchmark::RegisterBenchmark("BM_simple", BM_simple); benchmark::Initialize(&argc, argv); benchmark::RunSpecifiedBenchmarks();
diff --git a/examples/triangulate/main.cpp b/examples/triangulate/main.cpp index 2a90acb..fa82383 100644 --- a/examples/triangulate/main.cpp +++ b/examples/triangulate/main.cpp
@@ -1,7 +1,7 @@ #include "rapidjson/document.h" #include "rapidjson/prettywriter.h" #include <delaunator.hpp> -#include "../../test/test_utils.hpp" +#include "../utils.hpp" #include <cstdio> #include <fstream> #include <vector> @@ -62,8 +62,8 @@ int main(int, char* argv[]) { const char* filename = argv[1]; const char* output = argv[2]; - std::string json = test_utils::read_file(filename); - std::vector<double> coords = test_utils::get_geo_json_points(json); + std::string json = utils::read_file(filename); + std::vector<double> coords = utils::get_geo_json_points(json); delaunator::Delaunator delaunator(coords); const char* out_json = serialize_to_json(delaunator).c_str();
diff --git a/test/test_utils.hpp b/examples/utils.hpp similarity index 96% rename from test/test_utils.hpp rename to examples/utils.hpp index 2ad7e82..78e5735 100644 --- a/test/test_utils.hpp +++ b/examples/utils.hpp
@@ -2,7 +2,7 @@ #include <stdexcept> #include "rapidjson/document.h" -namespace test_utils { +namespace utils { std::string read_file(const char* filename) { std::ifstream input_file(filename); @@ -53,4 +53,4 @@ } -} // end ns test_utils +} // end ns utils
diff --git a/test/test_json_validate.cpp b/test/delaunator.test.cpp similarity index 94% rename from test/test_json_validate.cpp rename to test/delaunator.test.cpp index 74b7a0b..aac3093 100644 --- a/test/test_json_validate.cpp +++ b/test/delaunator.test.cpp
@@ -1,6 +1,6 @@ #include <delaunator.hpp> #include <catch.hpp> -#include "test_utils.hpp" +#include "../examples/utils.hpp" namespace { void validate(const std::vector<double> &coords) { @@ -19,10 +19,10 @@ } TEST_CASE("triangles match JS version ouput", "[Delaunator]") { - std::string points_str = test_utils::read_file("./test/test-files/playgrounds-1356-epsg-3857.geojson"); - std::string triangles_str = test_utils::read_file("./test/test-files/playgrounds-1356-triangles.json"); - std::vector<double> coords = test_utils::get_geo_json_points(points_str); - std::vector<double> triangles = test_utils::get_array_points(triangles_str); + std::string points_str = utils::read_file("./test/test-files/playgrounds-1356-epsg-3857.geojson"); + std::string triangles_str = utils::read_file("./test/test-files/playgrounds-1356-triangles.json"); + std::vector<double> coords = utils::get_geo_json_points(points_str); + std::vector<double> triangles = utils::get_array_points(triangles_str); delaunator::Delaunator delaunator(coords); SECTION("length of triangles is the same") { @@ -30,7 +30,7 @@ } SECTION("values are the same") { - for(size_t i = 0; i < triangles.size(); i++) + for(std::size_t i = 0; i < triangles.size(); i++) { REQUIRE(delaunator.triangles[i] == Approx(triangles[i])); }
diff --git a/test/test_main.cpp b/test/main.test.cpp similarity index 100% rename from test/test_main.cpp rename to test/main.test.cpp