Greenbone Vulnerability Management Libraries: util/jsonpull_tests.c File Reference

Greenbone Vulnerability Management Libraries 23.1.1

Macros | Functions
jsonpull_tests.c File Reference
`#include "json.c"`
`#include "jsonpull.c"`
`#include <cgreen/cgreen.h>`
`#include <cgreen/mocks.h>`
`#include <stdio.h>`

## Macros
#define | INIT_JSON_PARSER(json_string)
#define | INIT_READ_ERROR_JSON_PARSER(json_string)
#define | CLEANUP_JSON_PARSER
#define | CHECK_PATH_EQUALS(expected_path_str)
#define | JSON_READ_ERROR "error reading JSON stream: Input/output error"

## Functions
| Describe (jsonpull)
| BeforeEach (jsonpull)
| AfterEach (jsonpull)
static FILE * | fstropen_r (const char *str)
static ssize_t | read_with_error_on_eof (void *stream_cookie, char *buf, size_t size)
| Ensure (jsonpull, can_init_parser_with_defaults)
| Ensure (jsonpull, can_parse_false)
| Ensure (jsonpull, can_parse_true)
| Ensure (jsonpull, can_parse_null)
| Ensure (jsonpull, can_parse_empty_strings)
| Ensure (jsonpull, can_parse_strings_with_content)
| Ensure (jsonpull, can_parse_integer_numbers)
| Ensure (jsonpull, can_parse_floating_point_numbers)
| Ensure (jsonpull, can_parse_empty_arrays)
| Ensure (jsonpull, can_parse_single_elem_arrays)
| Ensure (jsonpull, can_parse_multiple_elem_arrays)
| Ensure (jsonpull, can_parse_empty_objects)
| Ensure (jsonpull, can_parse_single_elem_objects)
| Ensure (jsonpull, can_parse_multiple_elem_objects)
| Ensure (jsonpull, can_parse_nested_containers)
| Ensure (jsonpull, can_expand_arrays)
| Ensure (jsonpull, can_expand_objects)
| Ensure (jsonpull, fails_for_read_error)
| Ensure (jsonpull, fails_for_misspelled_true)
| Ensure (jsonpull, fails_for_incomplete_true)
| Ensure (jsonpull, fails_for_misspelled_false)
| Ensure (jsonpull, fails_for_misspelled_null)
| Ensure (jsonpull, fails_for_string_read_error)
| Ensure (jsonpull, fails_for_string_eof)
| Ensure (jsonpull, fails_for_overlong_string)
| Ensure (jsonpull, fails_for_invalid_string)
| Ensure (jsonpull, fails_for_number_read_error)
| Ensure (jsonpull, fails_for_overlong_number)
| Ensure (jsonpull, fails_for_invalid_number)
| Ensure (jsonpull, fails_for_array_eof)
| Ensure (jsonpull, fails_for_array_eof_after_value)
| Ensure (jsonpull, fails_for_array_eof_after_comma)
| Ensure (jsonpull, fails_for_array_read_error)
| Ensure (jsonpull, fails_for_invalid_array_bracket)
| Ensure (jsonpull, fails_for_invalid_array_bracket_after_value)
| Ensure (jsonpull, fails_for_invalid_array_other_char)
| Ensure (jsonpull, fails_for_invalid_array_other_char_after_value)
| Ensure (jsonpull, fails_for_object_key_eof)
| Ensure (jsonpull, fails_for_object_key_read_error)
| Ensure (jsonpull, fails_for_object_key_invalid_string)
| Ensure (jsonpull, fails_for_invalid_object_key_bracket)
| Ensure (jsonpull, fails_for_invalid_object_key_other_char)
| Ensure (jsonpull, fails_for_object_colon_eof)
| Ensure (jsonpull, fails_for_object_colon_read_error)
| Ensure (jsonpull, fails_for_object_colon_other_char)
| Ensure (jsonpull, fails_for_object_value_eof)
| Ensure (jsonpull, fails_for_object_value_read_error)
| Ensure (jsonpull, fails_for_object_value_curly_brace)
| Ensure (jsonpull, fails_for_object_value_square_bracket)
| Ensure (jsonpull, fails_for_object_eof_after_value)
| Ensure (jsonpull, fails_for_object_square_bracket_after_value)
| Ensure (jsonpull, fails_for_object_eof_after_comma)
| Ensure (jsonpull, fails_for_read_error_after_doc_end)
| Ensure (jsonpull, fails_for_content_after_doc_end)
| Ensure (jsonpull, fails_for_expand_before_container)
| Ensure (jsonpull, fails_for_expand_after_value)
| Ensure (jsonpull, fails_for_expand_invalid_content)
| Ensure (jsonpull, fails_for_expand_overlong)
| Ensure (jsonpull, fails_for_expand_unexpected_curly_brace)
| Ensure (jsonpull, fails_for_expand_unexpected_square_bracket)
| Ensure (jsonpull, fails_for_expand_eof)
| Ensure (jsonpull, fails_for_expand_read_error)
int | main (int argc, char **argv)

## Macro Definition Documentation

## ◆ CHECK_PATH_EQUALS

#define CHECK_PATH_EQUALS | ( |  | expected_path_str | ) |

Value:
path_str = gvm_json_path_to_string (event.path); \
assert_that (path_str, is_equal_to_string (expected_path_str)); \
g_free (path_str);
gvm_json_path_to_string
gchar * gvm_json_path_to_string(GQueue *path)
Converts a path as used by a JSON pull parser to a JSONPath string.
Definition jsonpull.c:909

## ◆ CLEANUP_JSON_PARSER

#define CLEANUP_JSON_PARSER

Value:
gvm_json_pull_event_cleanup (&event); \
gvm_json_pull_parser_cleanup (&parser); \
fclose (jsonstream);
gvm_json_pull_event_cleanup
void gvm_json_pull_event_cleanup(gvm_json_pull_event_t *event)
Frees all data of JSON pull event data structure.
Definition jsonpull.c:61

## ◆ INIT_JSON_PARSER

#define INIT_JSON_PARSER | ( |  | json_string | ) |

Value:
gvm_json_pull_event_t event; \
gvm_json_pull_parser_t parser; \
FILE *jsonstream; \
jsonstream = fstropen_r (json_string); \
gvm_json_pull_event_init (&event); \
gvm_json_pull_parser_init_full (&parser, jsonstream, 100, 4);
fstropen_r
static FILE * fstropen_r(const char *str)
Definition jsonpull_tests.c:25
gvm_json_pull_event_t
Event generated by the JSON pull parser.
Definition jsonpull.h:59
gvm_json_pull_parser_t
A json pull parser.
Definition jsonpull.h:86

## ◆ INIT_READ_ERROR_JSON_PARSER

#define INIT_READ_ERROR_JSON_PARSER | ( |  | json_string | ) |

Value:
gvm_json_pull_event_t event; \
gvm_json_pull_parser_t parser; \
FILE *jsonstream = fstropen_r (json_string); \
cookie_io_functions_t io_functions = {.read = read_with_error_on_eof, \
.write = NULL, \
.seek = NULL, \
.close = NULL}; \
FILE *errorstream = fopencookie (jsonstream, "r", io_functions); \
gvm_json_pull_event_init (&event); \
gvm_json_pull_parser_init_full (&parser, errorstream, 100, 4);
read_with_error_on_eof
static ssize_t read_with_error_on_eof(void *stream_cookie, char *buf, size_t size)
Definition jsonpull_tests.c:31

## ◆ JSON_READ_ERROR

#define JSON_READ_ERROR "error reading JSON stream: Input/output error"

## Function Documentation

## ◆ AfterEach()

AfterEach | ( | jsonpull |  | ) |

## ◆ BeforeEach()

BeforeEach | ( | jsonpull |  | ) |

## ◆ Describe()

Describe | ( | jsonpull |  | ) |

## ◆ Ensure() [1/62]

Ensure | ( | jsonpull | ,
|  | can_expand_arrays | )

## ◆ Ensure() [2/62]

Ensure | ( | jsonpull | ,
|  | can_expand_objects | )

## ◆ Ensure() [3/62]

Ensure | ( | jsonpull | ,
|  | can_init_parser_with_defaults | )

## ◆ Ensure() [4/62]

Ensure | ( | jsonpull | ,
|  | can_parse_empty_arrays | )

## ◆ Ensure() [5/62]

Ensure | ( | jsonpull | ,
|  | can_parse_empty_objects | )

## ◆ Ensure() [6/62]

Ensure | ( | jsonpull | ,
|  | can_parse_empty_strings | )

## ◆ Ensure() [7/62]

Ensure | ( | jsonpull | ,
|  | can_parse_false | )

## ◆ Ensure() [8/62]

Ensure | ( | jsonpull | ,
|  | can_parse_floating_point_numbers | )

## ◆ Ensure() [9/62]

Ensure | ( | jsonpull | ,
|  | can_parse_integer_numbers | )

## ◆ Ensure() [10/62]

Ensure | ( | jsonpull | ,
|  | can_parse_multiple_elem_arrays | )

## ◆ Ensure() [11/62]

Ensure | ( | jsonpull | ,
|  | can_parse_multiple_elem_objects | )

## ◆ Ensure() [12/62]

Ensure | ( | jsonpull | ,
|  | can_parse_nested_containers | )

## ◆ Ensure() [13/62]

Ensure | ( | jsonpull | ,
|  | can_parse_null | )

## ◆ Ensure() [14/62]

Ensure | ( | jsonpull | ,
|  | can_parse_single_elem_arrays | )

## ◆ Ensure() [15/62]

Ensure | ( | jsonpull | ,
|  | can_parse_single_elem_objects | )

## ◆ Ensure() [16/62]

Ensure | ( | jsonpull | ,
|  | can_parse_strings_with_content | )

## ◆ Ensure() [17/62]

Ensure | ( | jsonpull | ,
|  | can_parse_true | )

## ◆ Ensure() [18/62]

Ensure | ( | jsonpull | ,
|  | fails_for_array_eof | )

## ◆ Ensure() [19/62]

Ensure | ( | jsonpull | ,
|  | fails_for_array_eof_after_comma | )

## ◆ Ensure() [20/62]

Ensure | ( | jsonpull | ,
|  | fails_for_array_eof_after_value | )

## ◆ Ensure() [21/62]

Ensure | ( | jsonpull | ,
|  | fails_for_array_read_error | )

## ◆ Ensure() [22/62]

Ensure | ( | jsonpull | ,
|  | fails_for_content_after_doc_end | )

## ◆ Ensure() [23/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_after_value | )

## ◆ Ensure() [24/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_before_container | )

## ◆ Ensure() [25/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_eof | )

## ◆ Ensure() [26/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_invalid_content | )

## ◆ Ensure() [27/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_overlong | )

## ◆ Ensure() [28/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_read_error | )

## ◆ Ensure() [29/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_unexpected_curly_brace | )

## ◆ Ensure() [30/62]

Ensure | ( | jsonpull | ,
|  | fails_for_expand_unexpected_square_bracket | )

## ◆ Ensure() [31/62]

Ensure | ( | jsonpull | ,
|  | fails_for_incomplete_true | )

## ◆ Ensure() [32/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_array_bracket | )

## ◆ Ensure() [33/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_array_bracket_after_value | )

## ◆ Ensure() [34/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_array_other_char | )

## ◆ Ensure() [35/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_array_other_char_after_value | )

## ◆ Ensure() [36/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_number | )

## ◆ Ensure() [37/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_object_key_bracket | )

## ◆ Ensure() [38/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_object_key_other_char | )

## ◆ Ensure() [39/62]

Ensure | ( | jsonpull | ,
|  | fails_for_invalid_string | )

## ◆ Ensure() [40/62]

Ensure | ( | jsonpull | ,
|  | fails_for_misspelled_false | )

## ◆ Ensure() [41/62]

Ensure | ( | jsonpull | ,
|  | fails_for_misspelled_null | )

## ◆ Ensure() [42/62]

Ensure | ( | jsonpull | ,
|  | fails_for_misspelled_true | )

## ◆ Ensure() [43/62]

Ensure | ( | jsonpull | ,
|  | fails_for_number_read_error | )

## ◆ Ensure() [44/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_colon_eof | )

## ◆ Ensure() [45/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_colon_other_char | )

## ◆ Ensure() [46/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_colon_read_error | )

## ◆ Ensure() [47/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_eof_after_comma | )

## ◆ Ensure() [48/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_eof_after_value | )

## ◆ Ensure() [49/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_key_eof | )

## ◆ Ensure() [50/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_key_invalid_string | )

## ◆ Ensure() [51/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_key_read_error | )

## ◆ Ensure() [52/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_square_bracket_after_value | )

## ◆ Ensure() [53/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_value_curly_brace | )

## ◆ Ensure() [54/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_value_eof | )

## ◆ Ensure() [55/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_value_read_error | )

## ◆ Ensure() [56/62]

Ensure | ( | jsonpull | ,
|  | fails_for_object_value_square_bracket | )

## ◆ Ensure() [57/62]

Ensure | ( | jsonpull | ,
|  | fails_for_overlong_number | )

## ◆ Ensure() [58/62]

Ensure | ( | jsonpull | ,
|  | fails_for_overlong_string | )

## ◆ Ensure() [59/62]

Ensure | ( | jsonpull | ,
|  | fails_for_read_error | )

## ◆ Ensure() [60/62]

Ensure | ( | jsonpull | ,
|  | fails_for_read_error_after_doc_end | )

## ◆ Ensure() [61/62]

Ensure | ( | jsonpull | ,
|  | fails_for_string_eof | )

## ◆ Ensure() [62/62]

Ensure | ( | jsonpull | ,
|  | fails_for_string_read_error | )

## ◆ fstropen_r()

FILE * fstropen_r | ( | const char * | str | ) |
| inlinestatic

## ◆ main()

int main | ( | int | argc,
|  | char ** | argv )

## ◆ read_with_error_on_eof()

ssize_t read_with_error_on_eof | ( | void * | stream_cookie,
|  | char * | buf,
|  | size_t | size )
| static