Skip to content

Commit

Permalink
Test: Errors: Test OOM paths for binary type
Browse files Browse the repository at this point in the history
  • Loading branch information
tlsa committed Jul 20, 2024
1 parent 02a7f31 commit 2b69dff
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/units/errs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8914,6 +8914,7 @@ static bool test_err_load_alloc_oom_2(
" - &a1 {"
" kind: cat,\n"
" sound: meow,\n"
" bin: d2FsdGhhemFyYm9iYWx0aGF6YXI=,\n"
" position: &a2 [ 1, &my_value 2, 1],\n"
" flags: &a3 [\n"
" first,\n"
Expand All @@ -8924,6 +8925,7 @@ static bool test_err_load_alloc_oom_2(
" }\n"
" - kind: snake\n"
" sound: &a5 hiss\n"
" bin: &a8 d2FsdGhhemFyYm9iYWx0aGF6YXI=\n"
" position: &a6 [ 3, 1, 0]\n"
" flags: &a7 [\n"
" first,\n"
Expand All @@ -8935,13 +8937,16 @@ static bool test_err_load_alloc_oom_2(
" - *a1\n"
" - kind: snake\n"
" sound: *a5\n"
" bin: *a8\n"
" position: *a6\n"
" flags: *a7\n"
" value: *my_value\n";
struct animal_s {
char *kind;
char *sound;
int **position;
uint8_t *bin;
size_t bin_len;
unsigned position_count;
enum test_f *flags;
int value;
Expand All @@ -8961,6 +8966,8 @@ static bool test_err_load_alloc_oom_2(
CYAML_FIELD_SEQUENCE("position", CYAML_FLAG_POINTER,
struct animal_s, position,
&position_entry_schema, 0, CYAML_UNLIMITED),
CYAML_FIELD_BINARY("bin", CYAML_FLAG_POINTER,
struct animal_s, bin, 0, CYAML_UNLIMITED),
CYAML_FIELD_FLAGS("flags",
CYAML_FLAG_STRICT | CYAML_FLAG_POINTER,
struct animal_s, flags, strings, 4),
Expand Down Expand Up @@ -9199,6 +9206,7 @@ static bool test_err_save_alloc_oom_2(
"animals:\n"
" - kind: cat\n"
" sound: meow\n"
" bin: d2FsdGhhemFyYm9iYWx0aGF6YXI=\n"
" position: [ 1, 2, 1]\n"
" flags:\n"
" - first\n"
Expand All @@ -9207,6 +9215,7 @@ static bool test_err_save_alloc_oom_2(
" - fourth\n"
" - kind: snake\n"
" sound: hiss\n"
" bin: d2FsdGhhemFyYm9iYWx0aGF6YXI=\n"
" position: [ 3, 1, 0]\n"
" flags:\n"
" - first\n"
Expand All @@ -9217,6 +9226,8 @@ static bool test_err_save_alloc_oom_2(
char *kind;
char *sound;
int **position;
uint8_t *bin;
size_t bin_len;
unsigned position_count;
enum test_f *flags;
};
Expand All @@ -9235,6 +9246,8 @@ static bool test_err_save_alloc_oom_2(
CYAML_FIELD_SEQUENCE("position", CYAML_FLAG_POINTER,
struct animal_s, position,
&position_entry_schema, 0, CYAML_UNLIMITED),
CYAML_FIELD_BINARY("bin", CYAML_FLAG_POINTER,
struct animal_s, bin, 0, CYAML_UNLIMITED),
CYAML_FIELD_FLAGS("flags",
CYAML_FLAG_STRICT | CYAML_FLAG_POINTER,
struct animal_s, flags, strings, 4),
Expand Down Expand Up @@ -9479,6 +9492,7 @@ static bool test_err_copy_alloc_oom_2(
"animals:\n"
" - kind: cat\n"
" sound: meow\n"
" bin: d2FsdGhhemFyYm9iYWx0aGF6YXI=\n"
" position: [ 1, 2, 1]\n"
" flags:\n"
" - first\n"
Expand All @@ -9487,6 +9501,7 @@ static bool test_err_copy_alloc_oom_2(
" - fourth\n"
" - kind: snake\n"
" sound: hiss\n"
" bin: d2FsdGhhemFyYm9iYWx0aGF6YXI=\n"
" position: [ 3, 1, 0]\n"
" flags:\n"
" - first\n"
Expand All @@ -9497,6 +9512,8 @@ static bool test_err_copy_alloc_oom_2(
char *kind;
char *sound;
int **position;
uint8_t *bin;
size_t bin_len;
unsigned position_count;
enum test_f *flags;
};
Expand All @@ -9516,6 +9533,8 @@ static bool test_err_copy_alloc_oom_2(
CYAML_FIELD_SEQUENCE("position", CYAML_FLAG_POINTER,
struct animal_s, position,
&position_entry_schema, 0, CYAML_UNLIMITED),
CYAML_FIELD_BINARY("bin", CYAML_FLAG_POINTER,
struct animal_s, bin, 0, CYAML_UNLIMITED),
CYAML_FIELD_FLAGS("flags",
CYAML_FLAG_STRICT | CYAML_FLAG_POINTER,
struct animal_s, flags, strings, 4),
Expand Down

0 comments on commit 2b69dff

Please sign in to comment.