diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:22:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:22:53 +0000 |
commit | 3b149631f0eb732049e04fa0c89d09c7aa2376f9 (patch) | |
tree | 7049356b06fcdcdaf9dbae476f55a43942e7c25f /test/test-geoip-invalid-file.c | |
parent | Initial commit. (diff) | |
download | geoip-upstream.tar.xz geoip-upstream.zip |
Adding upstream version 1.6.12.upstream/1.6.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test-geoip-invalid-file.c')
-rw-r--r-- | test/test-geoip-invalid-file.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test-geoip-invalid-file.c b/test/test-geoip-invalid-file.c new file mode 100644 index 0000000..10fe246 --- /dev/null +++ b/test/test-geoip-invalid-file.c @@ -0,0 +1,29 @@ +#include "GeoIP.h" + +int main(void) { + GeoIP *gi = GeoIP_open(SRCDIR "/README.md", GEOIP_MEMORY_CACHE); + + /* We don't detect invalid files at load, unfortunately. */ + if (gi == NULL) { + fprintf(stderr, "Error opening database\n"); + return 1; + } + + const char *country = GeoIP_country_code_by_addr(gi, "24.24.24.24"); + if (country != NULL) { + fprintf(stderr, + "Received a non-NULL value on an invalid database from " + "GeoIP_country_code_by_addr\n"); + return 1; + } + + country = GeoIP_country_code_by_addr_v6(gi, "24.24.24.24"); + if (country != NULL) { + fprintf(stderr, + "Received a non-NULL value on an invalid database from " + "GeoIP_country_code_by_addr_v6\n"); + return 1; + } + + return 0; +} |