Skip to content

Commit

Permalink
Test coverage for one more error, excluding unreachable block from co…
Browse files Browse the repository at this point in the history
…verage
  • Loading branch information
Nick Rabinowitz committed Nov 25, 2023
1 parent a2adc04 commit f0f1b45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/apps/testapps/testPolyfillInternal.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ SUITE(polyfillInternal) {
H3_SET_BASE_CELL(cell, 123);
iter.cell = cell;

iterStepPolygonCompact(&iter);
t_assert(iter.error == E_CELL_INVALID,
"Got expected error for invalid cell");
t_assert(iter.cell == H3_NULL,
"Got null output for invalid cell at res");

iter = iterInitPolygonCompact(&sfGeoPolygon, 9, CONTAINMENT_FULL);
t_assertSuccess(iter.error);

// Give the iterator a cell with a bad base cell, at the target res
// (full containment)
cell = 0x89283470003ffff;
H3_SET_BASE_CELL(cell, 123);
iter.cell = cell;

iterStepPolygonCompact(&iter);
t_assert(iter.error == E_CELL_INVALID,
"Got expected error for invalid cell");
Expand Down
4 changes: 3 additions & 1 deletion src/h3lib/lib/polyfill.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ void iterStepPolygonCompact(IterCellsPolygonCompact *iter) {
}
BBox bbox;
H3Error bboxErr = cellToBBox(cell, &bbox, false);
if (bboxErr) {
if (NEVER(bboxErr != E_SUCCESS)) {
// Should be unreachable - invalid cells would be caught in
// the previous boundaryErr
iterErrorPolygonCompact(iter, bboxErr);
return;
}
Expand Down

0 comments on commit f0f1b45

Please sign in to comment.