Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Rabinowitz committed Nov 4, 2023
1 parent de71b07 commit 45255d5
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/apps/testapps/testPolygonToCellsExperimental.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "h3Index.h"
#include "latLng.h"
#include "polyfill.h"
#include "polygon.h"
#include "test.h"
#include "utility.h"

Expand Down Expand Up @@ -172,6 +173,21 @@ SUITE(polygonToCells) {
free(hexagons);
}

TEST(polygonToCellsFullContainment) {
int64_t numHexagons;
t_assertSuccess(H3_EXPORT(maxPolygonToCellsSize)(
&sfGeoPolygon, 9, FULL_CONTAINMENT, &numHexagons));
H3Index *hexagons = calloc(numHexagons, sizeof(H3Index));

t_assertSuccess(H3_EXPORT(polygonToCellsExperimental)(
&sfGeoPolygon, 9, FULL_CONTAINMENT, hexagons));
int64_t actualNumIndexes = countNonNullIndexes(hexagons, numHexagons);

t_assert(actualNumIndexes == 1175,
"got expected polygonToCells size (full containment mode)");
free(hexagons);
}

TEST(polygonToCellsHole) {
int64_t numHexagons;
t_assertSuccess(H3_EXPORT(maxPolygonToCellsSize)(&holeGeoPolygon, 9, 0,
Expand All @@ -187,6 +203,22 @@ SUITE(polygonToCells) {
free(hexagons);
}

TEST(polygonToCellsHoleFullContainment) {
int64_t numHexagons;
t_assertSuccess(H3_EXPORT(maxPolygonToCellsSize)(
&holeGeoPolygon, 9, FULL_CONTAINMENT, &numHexagons));
H3Index *hexagons = calloc(numHexagons, sizeof(H3Index));

t_assertSuccess(H3_EXPORT(polygonToCellsExperimental)(
&holeGeoPolygon, 9, FULL_CONTAINMENT, hexagons));
int64_t actualNumIndexes = countNonNullIndexes(hexagons, numHexagons);

t_assert(
actualNumIndexes == 1118,
"got expected polygonToCells size (hole, full containment mode)");
free(hexagons);
}

TEST(polygonToCellsEmpty) {
int64_t numHexagons;
t_assertSuccess(H3_EXPORT(maxPolygonToCellsSize)(&emptyGeoPolygon, 9, 0,
Expand Down

0 comments on commit 45255d5

Please sign in to comment.