Initial commit
This commit is contained in:
24
tests/11_sv_pack.c
Normal file
24
tests/11_sv_pack.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#define DEBUG
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "../include/sv.h"
|
||||
|
||||
int main(void){
|
||||
const char *s = "Hello";
|
||||
struct String_View sv = sv_strn(s, strlen(s));
|
||||
size_t offset = sv_pack_size(sv);
|
||||
unsigned char *buf = malloc(offset);
|
||||
|
||||
sv_pack(buf, sv);
|
||||
|
||||
struct String_View out = sv_unpack(buf);
|
||||
assert(out.len == strlen(s));
|
||||
assert( memcmp(out.buf, s, out.len) == 0);
|
||||
assert( sv_eq(sv, out));
|
||||
assert( sv_casecmp(sv, out ) == 0);
|
||||
free(buf);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user