ext/h3/src/src/apps/testapps/testH3Index.c in h3-3.6.2 vs ext/h3/src/src/apps/testapps/testH3Index.c in h3-3.7.1

- old
+ new

@@ -20,10 +20,11 @@ */ #include <stdio.h> #include <stdlib.h> #include <string.h> + #include "constants.h" #include "h3Index.h" #include "test.h" #include "utility.h" @@ -107,13 +108,42 @@ TEST(h3IsValidWithMode) { for (int i = 0; i <= 0xf; i++) { H3Index h = H3_INIT; H3_SET_MODE(h, i); - char failureMessage[BUFF_SIZE]; - sprintf(failureMessage, "h3IsValid failed on mode %d", i); - t_assert(!H3_EXPORT(h3IsValid)(h) || i == 1, failureMessage); + if (i == H3_HEXAGON_MODE) { + t_assert(H3_EXPORT(h3IsValid)(h), + "h3IsValid succeeds on valid mode"); + } else { + char failureMessage[BUFF_SIZE]; + sprintf(failureMessage, "h3IsValid failed on mode %d", i); + t_assert(!H3_EXPORT(h3IsValid)(h), failureMessage); + } } + } + + TEST(h3IsValidReservedBits) { + for (int i = 0; i < 8; i++) { + H3Index h = H3_INIT; + H3_SET_MODE(h, H3_HEXAGON_MODE); + H3_SET_RESERVED_BITS(h, i); + if (i == 0) { + t_assert(H3_EXPORT(h3IsValid)(h), + "h3IsValid succeeds on valid reserved bits"); + } else { + char failureMessage[BUFF_SIZE]; + sprintf(failureMessage, "h3IsValid failed on reserved bits %d", + i); + t_assert(!H3_EXPORT(h3IsValid)(h), failureMessage); + } + } + } + + TEST(h3IsValidHighBit) { + H3Index h = H3_INIT; + H3_SET_MODE(h, H3_HEXAGON_MODE); + H3_SET_HIGH_BIT(h, 1); + t_assert(!H3_EXPORT(h3IsValid)(h), "h3IsValid failed on high bit"); } TEST(h3BadDigitInvalid) { H3Index h = H3_INIT; // By default the first index digit is out of range.