From 37dac22ccc806f748a5e5509c8ef78696af7c104 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 09:34:04 -0700 Subject: [PATCH 01/14] stub for new res1 test --- src/apps/testapps/testCompactCells.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 94e1d01e8..cf4269263 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -91,6 +91,14 @@ SUITE(compactCells) { free(children); } + TEST(allRes0children) { + H3Index cells0[122]; + + H3_EXPORT(getRes0Cells)(&cells0); + + t_assert(cells0[0] == 0x8001fffffffffff, "got expected parent"); + } + TEST(res0) { int hexCount = NUM_BASE_CELLS; From a094639eecbe6940bea29c7d0425f46918a7d110 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 09:34:23 -0700 Subject: [PATCH 02/14] better name --- src/apps/testapps/testCompactCells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index cf4269263..79125f07f 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -91,7 +91,7 @@ SUITE(compactCells) { free(children); } - TEST(allRes0children) { + TEST(allRes1) { H3Index cells0[122]; H3_EXPORT(getRes0Cells)(&cells0); From a618a5ee9f3ade61c1e0bc2e44550306bb6c91e2 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 09:35:32 -0700 Subject: [PATCH 03/14] formatting is happening? --- src/apps/applib/include/args.h | 4 +-- src/apps/benchmarks/benchmarkGridPathCells.c | 10 +++----- src/apps/benchmarks/benchmarkH3Api.c | 5 ++-- src/apps/benchmarks/benchmarkVertex.c | 5 ++-- src/h3lib/include/h3Index.h | 27 +++++++++++--------- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/apps/applib/include/args.h b/src/apps/applib/include/args.h index 511913836..038038b03 100644 --- a/src/apps/applib/include/args.h +++ b/src/apps/applib/include/args.h @@ -90,7 +90,7 @@ int _parseArgsList(int argc, char *argv[], int numArgs, Arg *args[], // common arguments #define ARG_HELP \ - { .names = {"-h", "--help"}, .helpText = "Show this help message." } + {.names = {"-h", "--help"}, .helpText = "Show this help message."} #define DEFINE_INDEX_ARG(varName, argName) \ H3Index varName = 0; \ Arg argName = { \ @@ -109,7 +109,7 @@ int _parseArgsList(int argc, char *argv[], int numArgs, Arg *args[], .value = &varName, \ .helpText = "H3 Cell"} #define ARG_KML \ - { .names = {"-k", "--kml"}, .helpText = "Print output in KML format." } + {.names = {"-k", "--kml"}, .helpText = "Print output in KML format."} #define DEFINE_KML_NAME_ARG(varName, argName) \ char varName[BUFF_SIZE] = {0}; \ Arg argName = { \ diff --git a/src/apps/benchmarks/benchmarkGridPathCells.c b/src/apps/benchmarks/benchmarkGridPathCells.c index 2fcbaeb92..333fe967e 100644 --- a/src/apps/benchmarks/benchmarkGridPathCells.c +++ b/src/apps/benchmarks/benchmarkGridPathCells.c @@ -27,12 +27,10 @@ int64_t size; H3_EXPORT(gridPathCellsSize)(startIndex, endFar, &size); H3Index *out = calloc(size, sizeof(H3Index)); -BENCHMARK(gridPathCellsNear, 10000, { - H3_EXPORT(gridPathCells)(startIndex, endNear, out); -}); -BENCHMARK(gridPathCellsFar, 1000, { - H3_EXPORT(gridPathCells)(startIndex, endFar, out); -}); +BENCHMARK(gridPathCellsNear, 10000, + { H3_EXPORT(gridPathCells)(startIndex, endNear, out); }); +BENCHMARK(gridPathCellsFar, 1000, + { H3_EXPORT(gridPathCells)(startIndex, endFar, out); }); free(out); diff --git a/src/apps/benchmarks/benchmarkH3Api.c b/src/apps/benchmarks/benchmarkH3Api.c index d54b66597..22ec3ca8f 100644 --- a/src/apps/benchmarks/benchmarkH3Api.c +++ b/src/apps/benchmarks/benchmarkH3Api.c @@ -31,8 +31,7 @@ BENCHMARK(latLngToCell, 10000, { H3_EXPORT(latLngToCell)(&coord, 9, &h); }); BENCHMARK(cellToLatLng, 10000, { H3_EXPORT(cellToLatLng)(hex, &outCoord); }); -BENCHMARK(cellToBoundary, 10000, { - H3_EXPORT(cellToBoundary)(hex, &outBoundary); -}); +BENCHMARK(cellToBoundary, 10000, + { H3_EXPORT(cellToBoundary)(hex, &outBoundary); }); END_BENCHMARKS(); diff --git a/src/apps/benchmarks/benchmarkVertex.c b/src/apps/benchmarks/benchmarkVertex.c index a0bd6c01d..38e90cff0 100644 --- a/src/apps/benchmarks/benchmarkVertex.c +++ b/src/apps/benchmarks/benchmarkVertex.c @@ -44,9 +44,8 @@ H3Index *vertexes = calloc(6, sizeof(H3Index)); BENCHMARK(cellToVertexes, 10000, { H3_EXPORT(cellToVertexes)(hex, vertexes); }); -BENCHMARK(cellToVertexesPent, 10000, { - H3_EXPORT(cellToVertexes)(pentagon, vertexes); -}); +BENCHMARK(cellToVertexesPent, 10000, + { H3_EXPORT(cellToVertexes)(pentagon, vertexes); }); BENCHMARK(cellToVertexesRing, 10000, { for (int i = 0; i < ring2Count; i++) { diff --git a/src/h3lib/include/h3Index.h b/src/h3lib/include/h3Index.h index 6ced3c4cd..5dfa7ce3d 100644 --- a/src/h3lib/include/h3Index.h +++ b/src/h3lib/include/h3Index.h @@ -92,47 +92,50 @@ /** * Gets the highest bit of the H3 index. */ -#define H3_GET_HIGH_BIT(h3) ((int)((((h3)&H3_HIGH_BIT_MASK) >> H3_MAX_OFFSET))) +#define H3_GET_HIGH_BIT(h3) \ + ((int)((((h3) & H3_HIGH_BIT_MASK) >> H3_MAX_OFFSET))) /** * Sets the highest bit of the h3 to v. */ -#define H3_SET_HIGH_BIT(h3, v) \ - (h3) = (((h3)&H3_HIGH_BIT_MASK_NEGATIVE) | \ +#define H3_SET_HIGH_BIT(h3, v) \ + (h3) = (((h3) & H3_HIGH_BIT_MASK_NEGATIVE) | \ (((uint64_t)(v)) << H3_MAX_OFFSET)) /** * Gets the integer mode of h3. */ -#define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET))) +#define H3_GET_MODE(h3) ((int)((((h3) & H3_MODE_MASK) >> H3_MODE_OFFSET))) /** * Sets the integer mode of h3 to v. */ #define H3_SET_MODE(h3, v) \ - (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET)) + (h3) = \ + (((h3) & H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET)) /** * Gets the integer base cell of h3. */ -#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET))) +#define H3_GET_BASE_CELL(h3) ((int)((((h3) & H3_BC_MASK) >> H3_BC_OFFSET))) /** * Sets the integer base cell of h3 to bc. */ #define H3_SET_BASE_CELL(h3, bc) \ - (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET)) + (h3) = (((h3) & H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET)) /** * Gets the integer resolution of h3. */ -#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET))) +#define H3_GET_RESOLUTION(h3) ((int)((((h3) & H3_RES_MASK) >> H3_RES_OFFSET))) /** * Sets the integer resolution of h3. */ #define H3_SET_RESOLUTION(h3, res) \ - (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET)) + (h3) = \ + (((h3) & H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET)) /** * Gets the resolution res integer digit (0-7) of h3. @@ -145,15 +148,15 @@ * Sets a value in the reserved space. Setting to non-zero may produce invalid * indexes. */ -#define H3_SET_RESERVED_BITS(h3, v) \ - (h3) = (((h3)&H3_RESERVED_MASK_NEGATIVE) | \ +#define H3_SET_RESERVED_BITS(h3, v) \ + (h3) = (((h3) & H3_RESERVED_MASK_NEGATIVE) | \ (((uint64_t)(v)) << H3_RESERVED_OFFSET)) /** * Gets a value in the reserved space. Should always be zero for valid indexes. */ #define H3_GET_RESERVED_BITS(h3) \ - ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET))) + ((int)((((h3) & H3_RESERVED_MASK) >> H3_RESERVED_OFFSET))) /** * Sets the resolution res digit of h3 to the integer digit (0-7) From 63a27237d61fd8408dab1f0a582397b620f5c8e1 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 10:01:42 -0700 Subject: [PATCH 04/14] clean up test for all res 1 --- src/apps/testapps/testCompactCells.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 79125f07f..9dff87729 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -92,11 +92,20 @@ SUITE(compactCells) { } TEST(allRes1) { - H3Index cells0[122]; + int64_t numRes0 = 122; + int64_t numRes1 = 842; + H3Index cells0[numRes0]; + H3Index cells1[numRes1]; H3_EXPORT(getRes0Cells)(&cells0); + t_assert(cells0[0] == 0x8001fffffffffff, "got expected first res0 cell"); - t_assert(cells0[0] == 0x8001fffffffffff, "got expected parent"); + t_assertSuccess( + H3_EXPORT(uncompactCells)(cells0, numRes0, cells1, numRes1, 1)); + + H3Index out[numRes1]; + // also dies at 41! + t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numRes1)); } TEST(res0) { From e5fa3bb182106236163fcbff7caed52931e39c36 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 10:20:44 -0700 Subject: [PATCH 05/14] failing test --- src/apps/testapps/testCompactCells.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 9dff87729..363e93926 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -98,14 +98,22 @@ SUITE(compactCells) { H3Index cells1[numRes1]; H3_EXPORT(getRes0Cells)(&cells0); - t_assert(cells0[0] == 0x8001fffffffffff, "got expected first res0 cell"); + t_assert(cells0[0] == 0x8001fffffffffff, + "got expected first res0 cell"); t_assertSuccess( H3_EXPORT(uncompactCells)(cells0, numRes0, cells1, numRes1, 1)); H3Index out[numRes1]; - // also dies at 41! - t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numRes1)); + + // Fails at compactCells. + // However: + // Passes if numUncompacted <= 40 + // Fails if numUncompacted >= 41. + int64_t numUncompacted = numRes1; + t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted)); + + // TODO: check that output matches cells0 } TEST(res0) { From 8f778296777a0525de3efc19c73b3102c526fa90 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 10:25:38 -0700 Subject: [PATCH 06/14] Demonstrate pass at `numUncompacted = 40` --- src/apps/testapps/testCompactCells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 363e93926..9fe3c7eec 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -110,7 +110,7 @@ SUITE(compactCells) { // However: // Passes if numUncompacted <= 40 // Fails if numUncompacted >= 41. - int64_t numUncompacted = numRes1; + int64_t numUncompacted = 40; t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted)); // TODO: check that output matches cells0 From 944a62b04ef8420173fc56e964d6b501b07ad60d Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 10:33:34 -0700 Subject: [PATCH 07/14] retry: Demonstrate pass at `numUncompacted = 40` --- src/apps/testapps/testCompactCells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 9fe3c7eec..2887e4d8b 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -97,7 +97,7 @@ SUITE(compactCells) { H3Index cells0[numRes0]; H3Index cells1[numRes1]; - H3_EXPORT(getRes0Cells)(&cells0); + H3_EXPORT(getRes0Cells)(cells0); t_assert(cells0[0] == 0x8001fffffffffff, "got expected first res0 cell"); From 6159f5ca866a2b9c17c5784e44b44fe8190e3fea Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 10:51:30 -0700 Subject: [PATCH 08/14] should fix the formatting issue --- src/apps/applib/include/args.h | 4 +-- src/apps/benchmarks/benchmarkGridPathCells.c | 10 +++++--- src/apps/benchmarks/benchmarkH3Api.c | 5 ++-- src/apps/benchmarks/benchmarkVertex.c | 5 ++-- src/h3lib/include/h3Index.h | 27 +++++++++----------- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/apps/applib/include/args.h b/src/apps/applib/include/args.h index 038038b03..511913836 100644 --- a/src/apps/applib/include/args.h +++ b/src/apps/applib/include/args.h @@ -90,7 +90,7 @@ int _parseArgsList(int argc, char *argv[], int numArgs, Arg *args[], // common arguments #define ARG_HELP \ - {.names = {"-h", "--help"}, .helpText = "Show this help message."} + { .names = {"-h", "--help"}, .helpText = "Show this help message." } #define DEFINE_INDEX_ARG(varName, argName) \ H3Index varName = 0; \ Arg argName = { \ @@ -109,7 +109,7 @@ int _parseArgsList(int argc, char *argv[], int numArgs, Arg *args[], .value = &varName, \ .helpText = "H3 Cell"} #define ARG_KML \ - {.names = {"-k", "--kml"}, .helpText = "Print output in KML format."} + { .names = {"-k", "--kml"}, .helpText = "Print output in KML format." } #define DEFINE_KML_NAME_ARG(varName, argName) \ char varName[BUFF_SIZE] = {0}; \ Arg argName = { \ diff --git a/src/apps/benchmarks/benchmarkGridPathCells.c b/src/apps/benchmarks/benchmarkGridPathCells.c index 333fe967e..2fcbaeb92 100644 --- a/src/apps/benchmarks/benchmarkGridPathCells.c +++ b/src/apps/benchmarks/benchmarkGridPathCells.c @@ -27,10 +27,12 @@ int64_t size; H3_EXPORT(gridPathCellsSize)(startIndex, endFar, &size); H3Index *out = calloc(size, sizeof(H3Index)); -BENCHMARK(gridPathCellsNear, 10000, - { H3_EXPORT(gridPathCells)(startIndex, endNear, out); }); -BENCHMARK(gridPathCellsFar, 1000, - { H3_EXPORT(gridPathCells)(startIndex, endFar, out); }); +BENCHMARK(gridPathCellsNear, 10000, { + H3_EXPORT(gridPathCells)(startIndex, endNear, out); +}); +BENCHMARK(gridPathCellsFar, 1000, { + H3_EXPORT(gridPathCells)(startIndex, endFar, out); +}); free(out); diff --git a/src/apps/benchmarks/benchmarkH3Api.c b/src/apps/benchmarks/benchmarkH3Api.c index 22ec3ca8f..d54b66597 100644 --- a/src/apps/benchmarks/benchmarkH3Api.c +++ b/src/apps/benchmarks/benchmarkH3Api.c @@ -31,7 +31,8 @@ BENCHMARK(latLngToCell, 10000, { H3_EXPORT(latLngToCell)(&coord, 9, &h); }); BENCHMARK(cellToLatLng, 10000, { H3_EXPORT(cellToLatLng)(hex, &outCoord); }); -BENCHMARK(cellToBoundary, 10000, - { H3_EXPORT(cellToBoundary)(hex, &outBoundary); }); +BENCHMARK(cellToBoundary, 10000, { + H3_EXPORT(cellToBoundary)(hex, &outBoundary); +}); END_BENCHMARKS(); diff --git a/src/apps/benchmarks/benchmarkVertex.c b/src/apps/benchmarks/benchmarkVertex.c index 38e90cff0..a0bd6c01d 100644 --- a/src/apps/benchmarks/benchmarkVertex.c +++ b/src/apps/benchmarks/benchmarkVertex.c @@ -44,8 +44,9 @@ H3Index *vertexes = calloc(6, sizeof(H3Index)); BENCHMARK(cellToVertexes, 10000, { H3_EXPORT(cellToVertexes)(hex, vertexes); }); -BENCHMARK(cellToVertexesPent, 10000, - { H3_EXPORT(cellToVertexes)(pentagon, vertexes); }); +BENCHMARK(cellToVertexesPent, 10000, { + H3_EXPORT(cellToVertexes)(pentagon, vertexes); +}); BENCHMARK(cellToVertexesRing, 10000, { for (int i = 0; i < ring2Count; i++) { diff --git a/src/h3lib/include/h3Index.h b/src/h3lib/include/h3Index.h index 5dfa7ce3d..6ced3c4cd 100644 --- a/src/h3lib/include/h3Index.h +++ b/src/h3lib/include/h3Index.h @@ -92,50 +92,47 @@ /** * Gets the highest bit of the H3 index. */ -#define H3_GET_HIGH_BIT(h3) \ - ((int)((((h3) & H3_HIGH_BIT_MASK) >> H3_MAX_OFFSET))) +#define H3_GET_HIGH_BIT(h3) ((int)((((h3)&H3_HIGH_BIT_MASK) >> H3_MAX_OFFSET))) /** * Sets the highest bit of the h3 to v. */ -#define H3_SET_HIGH_BIT(h3, v) \ - (h3) = (((h3) & H3_HIGH_BIT_MASK_NEGATIVE) | \ +#define H3_SET_HIGH_BIT(h3, v) \ + (h3) = (((h3)&H3_HIGH_BIT_MASK_NEGATIVE) | \ (((uint64_t)(v)) << H3_MAX_OFFSET)) /** * Gets the integer mode of h3. */ -#define H3_GET_MODE(h3) ((int)((((h3) & H3_MODE_MASK) >> H3_MODE_OFFSET))) +#define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET))) /** * Sets the integer mode of h3 to v. */ #define H3_SET_MODE(h3, v) \ - (h3) = \ - (((h3) & H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET)) + (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET)) /** * Gets the integer base cell of h3. */ -#define H3_GET_BASE_CELL(h3) ((int)((((h3) & H3_BC_MASK) >> H3_BC_OFFSET))) +#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET))) /** * Sets the integer base cell of h3 to bc. */ #define H3_SET_BASE_CELL(h3, bc) \ - (h3) = (((h3) & H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET)) + (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET)) /** * Gets the integer resolution of h3. */ -#define H3_GET_RESOLUTION(h3) ((int)((((h3) & H3_RES_MASK) >> H3_RES_OFFSET))) +#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET))) /** * Sets the integer resolution of h3. */ #define H3_SET_RESOLUTION(h3, res) \ - (h3) = \ - (((h3) & H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET)) + (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET)) /** * Gets the resolution res integer digit (0-7) of h3. @@ -148,15 +145,15 @@ * Sets a value in the reserved space. Setting to non-zero may produce invalid * indexes. */ -#define H3_SET_RESERVED_BITS(h3, v) \ - (h3) = (((h3) & H3_RESERVED_MASK_NEGATIVE) | \ +#define H3_SET_RESERVED_BITS(h3, v) \ + (h3) = (((h3)&H3_RESERVED_MASK_NEGATIVE) | \ (((uint64_t)(v)) << H3_RESERVED_OFFSET)) /** * Gets a value in the reserved space. Should always be zero for valid indexes. */ #define H3_GET_RESERVED_BITS(h3) \ - ((int)((((h3) & H3_RESERVED_MASK) >> H3_RESERVED_OFFSET))) + ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET))) /** * Sets the resolution res digit of h3 to the integer digit (0-7) From d811d474297d25cb86bcd47f7e36bbd9a3807cb0 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 11:14:39 -0700 Subject: [PATCH 09/14] const array sizes to fix windows errors --- src/apps/testapps/testCompactCells.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 2887e4d8b..05ea031bb 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -92,8 +92,8 @@ SUITE(compactCells) { } TEST(allRes1) { - int64_t numRes0 = 122; - int64_t numRes1 = 842; + const int64_t numRes0 = 122; + const int64_t numRes1 = 842; H3Index cells0[numRes0]; H3Index cells1[numRes1]; From d29c9b3daac76862f547517a5f3b3bc04cfac1ed Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 11:33:19 -0700 Subject: [PATCH 10/14] bah --- src/apps/testapps/testCompactCells.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 05ea031bb..192fc4fee 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -94,8 +94,9 @@ SUITE(compactCells) { TEST(allRes1) { const int64_t numRes0 = 122; const int64_t numRes1 = 842; - H3Index cells0[numRes0]; - H3Index cells1[numRes1]; + H3Index *cells0 = calloc(numRes0, sizeof(H3Index)); + H3Index *cells1 = calloc(numRes1, sizeof(H3Index)); + H3Index *out = calloc(numRes1, sizeof(H3Index)); H3_EXPORT(getRes0Cells)(cells0); t_assert(cells0[0] == 0x8001fffffffffff, @@ -104,8 +105,6 @@ SUITE(compactCells) { t_assertSuccess( H3_EXPORT(uncompactCells)(cells0, numRes0, cells1, numRes1, 1)); - H3Index out[numRes1]; - // Fails at compactCells. // However: // Passes if numUncompacted <= 40 @@ -114,6 +113,10 @@ SUITE(compactCells) { t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted)); // TODO: check that output matches cells0 + + free(cells0); + free(cells1); + free(out); } TEST(res0) { From fa3b1b8040c34255ab67541ea9bae5952b34d2dd Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 11:42:42 -0700 Subject: [PATCH 11/14] Demonstrate failure at numUncompacted = 41 --- src/apps/testapps/testCompactCells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 192fc4fee..b7b45f7fb 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -109,7 +109,7 @@ SUITE(compactCells) { // However: // Passes if numUncompacted <= 40 // Fails if numUncompacted >= 41. - int64_t numUncompacted = 40; + int64_t numUncompacted = 41; t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted)); // TODO: check that output matches cells0 From e6c47e019068823c289c2597d8ec73856b5b2cc4 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 11:43:30 -0700 Subject: [PATCH 12/14] Demonstrate failure at numUncompacted = numRes1 = 842; --- src/apps/testapps/testCompactCells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index b7b45f7fb..b1ff58fea 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -109,7 +109,7 @@ SUITE(compactCells) { // However: // Passes if numUncompacted <= 40 // Fails if numUncompacted >= 41. - int64_t numUncompacted = 41; + int64_t numUncompacted = numRes1; t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted)); // TODO: check that output matches cells0 From a3a28e61804d6082a10adfa966d40e7301c2761e Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 11:44:11 -0700 Subject: [PATCH 13/14] Demonstrate pass at numUncompacted = 40 --- src/apps/testapps/testCompactCells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index b1ff58fea..192fc4fee 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -109,7 +109,7 @@ SUITE(compactCells) { // However: // Passes if numUncompacted <= 40 // Fails if numUncompacted >= 41. - int64_t numUncompacted = numRes1; + int64_t numUncompacted = 40; t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted)); // TODO: check that output matches cells0 From d97b939189a412fed8ea8f5d271e38cbcfb9a67c Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Thu, 26 Sep 2024 12:36:05 -0700 Subject: [PATCH 14/14] back to the full failing test demonstrating the problem --- src/apps/testapps/testCompactCells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/testapps/testCompactCells.c b/src/apps/testapps/testCompactCells.c index 192fc4fee..b1ff58fea 100644 --- a/src/apps/testapps/testCompactCells.c +++ b/src/apps/testapps/testCompactCells.c @@ -109,7 +109,7 @@ SUITE(compactCells) { // However: // Passes if numUncompacted <= 40 // Fails if numUncompacted >= 41. - int64_t numUncompacted = 40; + int64_t numUncompacted = numRes1; t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted)); // TODO: check that output matches cells0