Skip to content

Commit

Permalink
Merge pull request clwi#3 from speedyhoon/patch-1
Browse files Browse the repository at this point in the history
Fix example code
  • Loading branch information
clwi authored May 28, 2019
2 parents 2394729 + e459ba8 commit 43583ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void example (void)
{
cw_pack_context pc;
char buffer[20];
cw_pack_context_init (&pc, buffer, 20, 0, 0);
cw_pack_context_init (&pc, buffer, 20, 0);

cw_pack_map_size (&pc, 2);
cw_pack_str (&pc, "compact", 7);
Expand All @@ -42,20 +42,20 @@ void example (void)
if (length > 18) ERROR;

cw_unpack_context uc;
cw_unpack_context_init (&uc, pc.start, length, 0, 0);
cw_unpack_context_init (&uc, pc.start, length, 0);

cw_unpack_next(&uc);
if (uc.item.type != CWP_ITEM_MAP || uc.item.as.map.size != 2) ERROR;

cw_unpack_next(&uc);
if (uc.item.type != CWP_ITEM_STR || uc.item.as.str.length != 7)) ERROR;
if (uc.item.type != CWP_ITEM_STR || uc.item.as.str.length != 7) ERROR;
if (strncmp("compact", uc.item.as.str.start, 7)) ERROR;

cw_unpack_next(&uc);
if (uc.item.type != CWP_ITEM_BOOLEAN || uc.item.as.boolean != true) ERROR;

cw_unpack_next(&uc);
if (uc.item.type != CWP_ITEM_STR || uc.item.as.str.length != 6)) ERROR;
if (uc.item.type != CWP_ITEM_STR || uc.item.as.str.length != 6) ERROR;
if (strncmp("schema", uc.item.as.str.start, 6)) ERROR;

cw_unpack_next(&uc);
Expand Down

0 comments on commit 43583ff

Please sign in to comment.