jsonpull_tests.c File Reference
`#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_json_escape_strings)
| 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:973

## 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:133

## 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:24
gvm_json_pull_event_t
Event generated by the JSON pull parser.
Definition jsonpull.h:58
gvm_json_pull_parser_t
A json pull parser.
Definition jsonpull.h:85

## 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:30

## 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/63]

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

## Ensure() [2/63]

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

## Ensure() [3/63]

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

## Ensure() [4/63]

Ensure | ( | jsonpull | ,
|  | can_json_escape_strings |
| ) |  |

## Ensure() [5/63]

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

## Ensure() [6/63]

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

## Ensure() [7/63]

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

## Ensure() [8/63]

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

## Ensure() [9/63]

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

## Ensure() [10/63]

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

## Ensure() [11/63]

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

## Ensure() [12/63]

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

## Ensure() [13/63]

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

## Ensure() [14/63]

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

## Ensure() [15/63]

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

## Ensure() [16/63]

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

## Ensure() [17/63]

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

## Ensure() [18/63]

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

## Ensure() [19/63]

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

## Ensure() [20/63]

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

## Ensure() [21/63]

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

## Ensure() [22/63]

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

## Ensure() [23/63]

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

## Ensure() [24/63]

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

## Ensure() [25/63]

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

## Ensure() [26/63]

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

## Ensure() [27/63]

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

## Ensure() [28/63]

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

## Ensure() [29/63]

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

## Ensure() [30/63]

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

## Ensure() [31/63]

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

## Ensure() [32/63]

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

## Ensure() [33/63]

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

## Ensure() [34/63]

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

## Ensure() [35/63]

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

## Ensure() [36/63]

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

## Ensure() [37/63]

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

## Ensure() [38/63]

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

## Ensure() [39/63]

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

## Ensure() [40/63]

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

## Ensure() [41/63]

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

## Ensure() [42/63]

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

## Ensure() [43/63]

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

## Ensure() [44/63]

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

## Ensure() [45/63]

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

## Ensure() [46/63]

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

## Ensure() [47/63]

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

## Ensure() [48/63]

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

## Ensure() [49/63]

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

## Ensure() [50/63]

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

## Ensure() [51/63]

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

## Ensure() [52/63]

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

## Ensure() [53/63]

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

## Ensure() [54/63]

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

## Ensure() [55/63]

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

## Ensure() [56/63]

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

## Ensure() [57/63]

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

## Ensure() [58/63]

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

## Ensure() [59/63]

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

## Ensure() [60/63]

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

## Ensure() [61/63]

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

## Ensure() [62/63]

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

## Ensure() [63/63]

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

## fstropen_r()

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

inline static

## main()

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

## read_with_error_on_eof()

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

static