END_TEST START_TEST (null_node) { reset_errno(); assert_null(node_name(NULL)); assert_errno(EINVAL); reset_errno(); assert_node_size(NULL, 0); assert_errno(EINVAL); }
END_TEST START_TEST (document_type) { reset_errno(); size_t c = model_size(model); assert_noerr(); assert_uint_eq(1, c); reset_errno(); Document *d = model_document(model, 0); assert_noerr(); assert_not_null(d); reset_errno(); Node *bogus = model_document(model, 1); assert_errno(EINVAL); assert_null(bogus); reset_errno(); Node *r1 = model_document_root(model, 0); assert_noerr(); assert_not_null(r1); assert_node_kind(r1, MAPPING); reset_errno(); Node *r2 = document_root(d); assert_noerr(); assert_not_null(r2); assert_ptr_eq(r1, r2); }
END_TEST START_TEST (null_sequence) { reset_errno(); assert_null(sequence_get(NULL, 0)); assert_errno(EINVAL); }
END_TEST START_TEST (null_scalar) { reset_errno(); assert_null(scalar_value(NULL)); assert_errno(EINVAL); }
END_TEST START_TEST (null_document) { reset_errno(); assert_null(document_root(NULL)); assert_errno(EINVAL); }
END_TEST START_TEST (null_context) { reset_errno(); assert_null(load(NULL)); assert_errno(EINVAL); }
END_TEST START_TEST (bogus_context) { reset_errno(); assert_null(parse(NULL)); assert_errno(EINVAL); }
END_TEST START_TEST (null_mapping) { reset_errno(); assert_null(mapping_get(NULL, NULL, 0)); assert_errno(EINVAL); }
int init_kqueue(void) { int kq; int res; struct kevent ke; static struct timespec t0; kq = kqueue(); assert_errno("kqueue", kq >= 0); EV_SET(&ke, 1, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, 1, 0); res = kevent(kq, &ke, 1, NULL, 0, &t0); assert_errno("kevent", res == 0); return kq; }
END_TEST START_TEST (null_context_parser) { loader_context *loader = (loader_context *)calloc(1, sizeof(loader_context)); loader->parser = NULL; reset_errno(); assert_null(load(loader)); assert_errno(EINVAL); free(loader); }
END_TEST START_TEST (zero_length) { char *expression = ""; reset_errno(); parser_context *context = make_parser((uint8_t *)expression, 0); assert_not_null(context); assert_errno(EINVAL); assert_parser_failure(expression, context, NULL, ERR_ZERO_LENGTH, 0); parser_free(context); }
END_TEST START_TEST (null_file_input) { reset_errno(); loader_context *loader = make_file_loader(NULL); assert_not_null(loader); assert_errno(EINVAL); assert_loader_failure(loader, ERR_INPUT_IS_NULL); loader_free(loader); }
END_TEST START_TEST (zero_string_input_length) { reset_errno(); loader_context *loader = make_string_loader((unsigned char *)"", 0); assert_not_null(loader); assert_errno(EINVAL); assert_loader_failure(loader, ERR_INPUT_SIZE_IS_ZERO); loader_free(loader); }
int read_kevent(int kq) { int res; struct kevent ke; //static struct timespec t0; res = kevent(kq, NULL, 0, &ke, 1, NULL); assert_errno("kevent", res >= 0); fprintf(stdout, "kevent.data = %ld\n", ke.data); return (res < 0); }
END_TEST START_TEST (bogus_context_path) { uint8_t bogus_input = 64; parser_context context; context.path = NULL; context.input = &bogus_input; context.length = 5; reset_errno(); assert_null(parse(&context)); assert_errno(EINVAL); }
END_TEST START_TEST (bogus_context_input) { jsonpath bogus_path; parser_context context; context.path = &bogus_path; context.input = NULL; context.length = 5; reset_errno(); assert_null(parse(&context)); assert_errno(EINVAL); }
END_TEST START_TEST (bogus_context_length) { jsonpath bogus_path; uint8_t bogus_input = 64; parser_context context; context.path = &bogus_path; context.input = &bogus_input; context.length = 0; reset_errno(); assert_null(parse(&context)); assert_errno(EINVAL); }
END_TEST START_TEST (eof_file_input) { FILE *input = tmpfile(); fseek(input, 0, SEEK_END); reset_errno(); loader_context *loader = make_file_loader(input); assert_not_null(loader); assert_errno(EINVAL); assert_loader_failure(loader, ERR_INPUT_SIZE_IS_ZERO); fclose(input); loader_free(loader); }