2018-04-02 19:17:56 +00:00
|
|
|
/* Copyright (c) 2017 - 2018 LiteSpeed Technologies Inc. See LICENSE. */
|
2017-09-22 21:00:03 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
2018-03-12 22:25:01 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <vc_compat.h>
|
|
|
|
#endif
|
2017-09-22 21:00:03 +00:00
|
|
|
|
|
|
|
#include "lsquic_buf.h"
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
struct lsquic_buf *buf;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
buf = lsquic_buf_create(10);
|
|
|
|
assert(buf);
|
|
|
|
|
|
|
|
assert(0 == lsquic_buf_size(buf));
|
|
|
|
assert(10 == lsquic_buf_avail(buf));
|
|
|
|
assert(10 == lsquic_buf_capacity(buf));
|
|
|
|
|
|
|
|
s = lsquic_buf_append(NULL, NULL, 0);
|
|
|
|
assert(s < 0);
|
|
|
|
s = lsquic_buf_append(buf, (void *) 123, -1);
|
|
|
|
assert(s < 0);
|
|
|
|
|
|
|
|
s = lsquic_buf_append(buf, "dude", 4);
|
|
|
|
assert(4 == s);
|
|
|
|
assert(4 == lsquic_buf_size(buf));
|
|
|
|
assert(6 == lsquic_buf_avail(buf));
|
|
|
|
assert(10 == lsquic_buf_capacity(buf));
|
|
|
|
|
|
|
|
s = lsquic_buf_append(buf, ", where is my car?!", 20);
|
|
|
|
assert(20 == s);
|
|
|
|
assert(4 + 20 == lsquic_buf_size(buf));
|
|
|
|
|
|
|
|
assert(0 == strcasecmp(lsquic_buf_begin(buf), "Dude, where is my car?!"));
|
|
|
|
/* Yeah, where's your car, dude? */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|