Skip to content

Commit b59810e

Browse files
committed
move utils
1 parent f2ef8eb commit b59810e

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

bench/run.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
#include <benchmark/benchmark.h>
22
#include <string>
33
#include <delaunator.hpp>
4-
#include "../test/test_utils.hpp"
4+
#include "../examples/utils.hpp"
55

6-
static void BM_simple(benchmark::State& state) // NOLINT google-runtime-references
7-
{
8-
std::string points_str = test_utils::read_file("./test/test-files/osm-nodes-45331-epsg-3857.geojson");
9-
std::vector<double> coords = test_utils::get_geo_json_points(points_str);
10-
11-
while (state.KeepRunning())
6+
namespace {
7+
void BM_simple(benchmark::State& state)
128
{
13-
delaunator::Delaunator delaunator(coords);
9+
std::string points_str = utils::read_file("./test/test-files/osm-nodes-45331-epsg-3857.geojson");
10+
std::vector<double> coords = utils::get_geo_json_points(points_str);
11+
12+
while (state.KeepRunning())
13+
{
14+
delaunator::Delaunator delaunator(coords);
15+
}
1416
}
1517
}
1618

1719
int main(int argc, char* argv[])
1820
{
19-
benchmark::RegisterBenchmark("BM_simple", BM_simple); // NOLINT clang-analyzer-cplusplus.NewDeleteLeaks
21+
benchmark::RegisterBenchmark("BM_simple", BM_simple);
2022
benchmark::Initialize(&argc, argv);
2123
benchmark::RunSpecifiedBenchmarks();
2224

examples/triangulate/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "rapidjson/document.h"
22
#include "rapidjson/prettywriter.h"
33
#include <delaunator.hpp>
4-
#include "../../test/test_utils.hpp"
4+
#include "../utils.hpp"
55
#include <cstdio>
66
#include <fstream>
77
#include <vector>
@@ -62,8 +62,8 @@ std::string serialize_to_json(delaunator::Delaunator const& delaunator) {
6262
int main(int, char* argv[]) {
6363
const char* filename = argv[1];
6464
const char* output = argv[2];
65-
std::string json = test_utils::read_file(filename);
66-
std::vector<double> coords = test_utils::get_geo_json_points(json);
65+
std::string json = utils::read_file(filename);
66+
std::vector<double> coords = utils::get_geo_json_points(json);
6767
delaunator::Delaunator delaunator(coords);
6868
const char* out_json = serialize_to_json(delaunator).c_str();
6969

test/test_utils.hpp renamed to examples/utils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <stdexcept>
33
#include "rapidjson/document.h"
44

5-
namespace test_utils {
5+
namespace utils {
66

77
std::string read_file(const char* filename) {
88
std::ifstream input_file(filename);
@@ -53,4 +53,4 @@ std::vector<double> get_array_points(std::string const& json) {
5353

5454
}
5555

56-
} // end ns test_utils
56+
} // end ns utils

test/test_json_validate.cpp renamed to test/delaunator.test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <delaunator.hpp>
22
#include <catch.hpp>
3-
#include "test_utils.hpp"
3+
#include "../examples/utils.hpp"
44

55
namespace {
66
void validate(const std::vector<double> &coords) {
@@ -19,18 +19,18 @@ namespace {
1919
}
2020

2121
TEST_CASE("triangles match JS version ouput", "[Delaunator]") {
22-
std::string points_str = test_utils::read_file("./test/test-files/playgrounds-1356-epsg-3857.geojson");
23-
std::string triangles_str = test_utils::read_file("./test/test-files/playgrounds-1356-triangles.json");
24-
std::vector<double> coords = test_utils::get_geo_json_points(points_str);
25-
std::vector<double> triangles = test_utils::get_array_points(triangles_str);
22+
std::string points_str = utils::read_file("./test/test-files/playgrounds-1356-epsg-3857.geojson");
23+
std::string triangles_str = utils::read_file("./test/test-files/playgrounds-1356-triangles.json");
24+
std::vector<double> coords = utils::get_geo_json_points(points_str);
25+
std::vector<double> triangles = utils::get_array_points(triangles_str);
2626
delaunator::Delaunator delaunator(coords);
2727

2828
SECTION("length of triangles is the same") {
2929
REQUIRE(delaunator.triangles.size() == triangles.size());
3030
}
3131

3232
SECTION("values are the same") {
33-
for(size_t i = 0; i < triangles.size(); i++)
33+
for(std::size_t i = 0; i < triangles.size(); i++)
3434
{
3535
REQUIRE(delaunator.triangles[i] == Approx(triangles[i]));
3636
}
File renamed without changes.

0 commit comments

Comments
 (0)