22 lines
523 B
C
22 lines
523 B
C
|
|
#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";
|
||
|
|
size_t offset = strlen(s) + sizeof(uint64_t);
|
||
|
|
unsigned char *buf = malloc(offset);
|
||
|
|
struct String_View sv = sv_strn(s, strlen(s));
|
||
|
|
sv_pack(buf, sv);
|
||
|
|
|
||
|
|
struct String_View out = sv_unpack(buf);
|
||
|
|
assert(out.len == strlen(s));
|
||
|
|
assert( memcmp(out.buf, s, out.len) == 0);
|
||
|
|
free(buf);
|
||
|
|
return EXIT_SUCCESS;
|
||
|
|
}
|