"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/dump_t.c" between
libmaxminddb-1.5.0.tar.gz and libmaxminddb-1.5.2.tar.gz

About: libmaxminddb is a library that provides functions for working with MaxMind DB files (free GeoLite 2 or commercial GeoIP2).

dump_t.c  (libmaxminddb-1.5.0):dump_t.c  (libmaxminddb-1.5.2)
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#include "maxminddb_test_helper.h" #include "maxminddb_test_helper.h"
#ifdef HAVE_OPEN_MEMSTREAM #ifdef HAVE_OPEN_MEMSTREAM
void run_tests(int mode, const char *mode_desc) void run_tests(int mode, const char *mode_desc) {
{
const char *filename = "MaxMind-DB-test-decoder.mmdb"; const char *filename = "MaxMind-DB-test-decoder.mmdb";
const char *path = test_database_path(filename); const char *path = test_database_path(filename);
MMDB_s *mmdb = open_ok(path, mode, mode_desc); MMDB_s *mmdb = open_ok(path, mode, mode_desc);
free((void *)path); free((void *)path);
const char *ip = "1.1.1.1"; const char *ip = "1.1.1.1";
MMDB_lookup_result_s result = MMDB_lookup_result_s result =
lookup_string_ok(mmdb, ip, filename, mode_desc); lookup_string_ok(mmdb, ip, filename, mode_desc);
MMDB_entry_data_list_s *entry_data_list; MMDB_entry_data_list_s *entry_data_list;
int status = MMDB_get_entry_data_list(&result.entry, &entry_data_list); int status = MMDB_get_entry_data_list(&result.entry, &entry_data_list);
ok(MMDB_SUCCESS == status, ok(MMDB_SUCCESS == status, "MMDB_get_entry_data_list is successful");
"MMDB_get_entry_data_list is successful");
char *dump_output; char *dump_output;
size_t dump_size; size_t dump_size;
FILE *stream = open_memstream(&dump_output, &dump_size); FILE *stream = open_memstream(&dump_output, &dump_size);
status = MMDB_dump_entry_data_list(stream, entry_data_list, 0); status = MMDB_dump_entry_data_list(stream, entry_data_list, 0);
fclose(stream); fclose(stream);
MMDB_free_entry_data_list(entry_data_list); MMDB_free_entry_data_list(entry_data_list);
ok(MMDB_SUCCESS == status, ok(MMDB_SUCCESS == status,
"MMDB_dump_entry_data_list is successful - %s", "MMDB_dump_entry_data_list is successful - %s",
mode_desc); mode_desc);
cmp_ok(dump_size, ">", 0, "MMDB_dump produced output - %s", mode_desc); cmp_ok(dump_size, ">", 0, "MMDB_dump produced output - %s", mode_desc);
char *expect[] = { char *expect[] = {"{",
"{", " \"array\": ",
" \"array\": ", " [",
" [", " 1 <uint32>",
" 1 <uint32>", " 2 <uint32>",
" 2 <uint32>", " 3 <uint32>",
" 3 <uint32>", " ]",
" ]", " \"boolean\": ",
" \"boolean\": ", " true <boolean>",
" true <boolean>", " \"bytes\": ",
" \"bytes\": ", " 0000002A <bytes>",
" 0000002A <bytes>", " \"double\": ",
" \"double\": ", " 42.123456 <double>",
" 42.123456 <double>", " \"float\": ",
" \"float\": ", " 1.100000 <float>",
" 1.100000 <float>", " \"int32\": ",
" \"int32\": ", " -268435456 <int32>",
" -268435456 <int32>", " \"map\": ",
" \"map\": ", " {",
" {", " \"mapX\": ",
" \"mapX\": ", " {",
" {", " \"arrayX\": ",
" \"arrayX\": ", " [",
" [", " 7 <uint32>",
" 7 <uint32>", " 8 <uint32>",
" 8 <uint32>", " 9 <uint32>",
" 9 <uint32>", " ]",
" ]", " \"utf8_stringX\": ",
" \"utf8_stringX\": ", " \"hello\" <utf8_string>",
" \"hello\" <utf8_string>", " }",
" }", " }",
" }", " \"uint128\": ",
" \"uint128\": ", " 0x01000000000000000000000000000000 <uint128>",
" 0x01000000000000000000000000000000 <uint128>", " \"uint16\": ",
" \"uint16\": ", " 100 <uint16>",
" 100 <uint16>", " \"uint32\": ",
" \"uint32\": ", " 268435456 <uint32>",
" 268435456 <uint32>", " \"uint64\": ",
" \"uint64\": ", " 1152921504606846976 <uint64>",
" 1152921504606846976 <uint64>", " \"utf8_string\": ",
" \"utf8_string\": ", " \"unicode! ☯ - ♫\" <utf8_string>",
" \"unicode! ☯ - ♫\" <utf8_string>", "}"};
"}"
};
for (int i = 0; i < 42; i++) { for (int i = 0; i < 42; i++) {
ok((strstr(dump_output, expect[i]) != NULL), ok((strstr(dump_output, expect[i]) != NULL),
"dump output contains expected line (%s) - %s", expect[i], "dump output contains expected line (%s) - %s",
expect[i],
mode_desc); mode_desc);
} }
free(dump_output); free(dump_output);
MMDB_close(mmdb); MMDB_close(mmdb);
free(mmdb); free(mmdb);
} }
int main(void) int main(void) {
{
plan(NO_PLAN); plan(NO_PLAN);
for_all_modes(&run_tests); for_all_modes(&run_tests);
done_testing(); done_testing();
} }
#else #else
int main(void) int main(void) {
{
plan(SKIP_ALL, "This test requires the open_memstream() function"); plan(SKIP_ALL, "This test requires the open_memstream() function");
} }
#endif #endif
 End of changes. 6 change blocks. 
53 lines changed or deleted 48 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)