diff --git a/test/codec.c b/test/codec.c index 4a94cdd..3e55a16 100644 --- a/test/codec.c +++ b/test/codec.c @@ -106,27 +106,28 @@ test_codec_ack() static int test_codec_file() { + int rv; nftp * p; size_t len; uint8_t *v; uint8_t demo1_file[] = { - 0x03, 0x00, 0x00, 0x00, 0x13, // type & length + 0x03, 0x00, 0x00, 0x00, 0x15, // type & length 0x7c, 0x6d, 0x8b, 0xab, // fileid - 0x00, 0x02, 0x00, 0x06, // blockseq & length of content + 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, // blockseq & length of content 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 // content }; assert(0 == nftp_alloc(&p)); - assert(0 == nftp_decode(p, demo1_file, sizeof(demo1_file))); + assert(0 == (rv = nftp_decode(p, demo1_file, sizeof(demo1_file)))); assert(NFTP_TYPE_FILE == p->type); assert(sizeof(demo1_file) == p->len); assert(((0x7c << 24) + (0x6d << 16) + (0x8b << 8) + (0xab)) == p->fileid); assert(2 == p->blockseq); assert(6 == p->ctlen); - assert(0 == strncmp((char *)(demo1_file + 13), (char *)p->content, 6)); + assert(0 == strncmp((char *)(demo1_file + 15), (char *)p->content, 6)); assert(0 == nftp_encode(p, &v, &len)); assert(sizeof(demo1_file) == len); @@ -147,9 +148,9 @@ test_codec_end() uint8_t *v; uint8_t demo1_end[] = { - 0x04, 0x00, 0x00, 0x00, 0x13, // type & length + 0x04, 0x00, 0x00, 0x00, 0x15, // type & length 0x7c, 0x6d, 0x8b, 0xab, // fileid - 0x00, 0x02, 0x00, 0x06, // blockseq & length of content + 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, // blockseq & length of content 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 // content }; @@ -160,7 +161,7 @@ test_codec_end() assert(NFTP_TYPE_END == p->type); assert(sizeof(demo1_end) == p->len); assert(((0x7c << 24) + (0x6d << 16) + (0x8b << 8) + (0xab)) == p->fileid); - assert(0 == strncmp((char *)(demo1_end + 13), (char *)p->content, 6)); + assert(0 == strncmp((char *)(demo1_end + 15), (char *)p->content, 6)); assert(0 == nftp_encode(p, &v, &len)); assert(sizeof(demo1_end) == len);