"Fossies" - the Fresh Open Source Software Archive

Member "libmaxminddb-1.5.2/t/ipv4_start_cache_t.c" (18 Feb 2021, 1008 Bytes) of package /linux/misc/libmaxminddb-1.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "ipv4_start_cache_t.c": 1.5.0_vs_1.5.2.

    1 #include "maxminddb_test_helper.h"
    2 
    3 void test_one_ip(MMDB_s *mmdb,
    4                  const char *ip,
    5                  const char *filename,
    6                  const char *mode_desc) {
    7     MMDB_lookup_result_s result =
    8         lookup_string_ok(mmdb, ip, filename, mode_desc);
    9 
   10     ok(result.found_entry,
   11        "got a result for an IPv4 address included in a larger-than-IPv4 subnet "
   12        "- %s - %s",
   13        ip,
   14        mode_desc);
   15 
   16     data_ok(&result, MMDB_DATA_TYPE_UTF8_STRING, "string value for IP", NULL);
   17 }
   18 
   19 void run_tests(int mode, const char *mode_desc) {
   20     const char *filename = "MaxMind-DB-no-ipv4-search-tree.mmdb";
   21     const char *path = test_database_path(filename);
   22     MMDB_s *mmdb = open_ok(path, mode, mode_desc);
   23     free((void *)path);
   24 
   25     test_one_ip(mmdb, "1.1.1.1", filename, mode_desc);
   26     test_one_ip(mmdb, "255.255.255.255", filename, mode_desc);
   27 
   28     MMDB_close(mmdb);
   29     free(mmdb);
   30 }
   31 
   32 int main(void) {
   33     plan(NO_PLAN);
   34     for_all_modes(&run_tests);
   35     done_testing();
   36 }