"Fossies" - the Fresh Open Source Software Archive

Member "libmaxminddb-1.5.2/t/no_map_get_value_t.c" (18 Feb 2021, 970 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 "no_map_get_value_t.c": 1.5.0_vs_1.5.2.

    1 #include "maxminddb_test_helper.h"
    2 
    3 void run_tests(int mode, const char *mode_desc) {
    4     const char *filename = "MaxMind-DB-string-value-entries.mmdb";
    5     const char *path = test_database_path(filename);
    6     MMDB_s *mmdb = open_ok(path, mode, mode_desc);
    7     free((void *)path);
    8 
    9     const char *ip = "1.1.1.1";
   10     MMDB_lookup_result_s result =
   11         lookup_string_ok(mmdb, ip, filename, mode_desc);
   12 
   13     MMDB_entry_data_s entry_data;
   14     int status = MMDB_get_value(&result.entry, &entry_data, NULL);
   15 
   16     cmp_ok(status,
   17            "==",
   18            MMDB_SUCCESS,
   19            "status for MMDB_get_value() is MMDB_SUCCESS");
   20     ok(entry_data.has_data, "found a value when varargs list is just NULL");
   21     cmp_ok(entry_data.type,
   22            "==",
   23            MMDB_DATA_TYPE_UTF8_STRING,
   24            "returned entry type is utf8_string");
   25 
   26     MMDB_close(mmdb);
   27     free(mmdb);
   28 }
   29 
   30 int main(void) {
   31     plan(NO_PLAN);
   32     for_all_modes(&run_tests);
   33     done_testing();
   34 }