buffer_test.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <atf-c.h>
#include "isctest.h"
}
isc_buffer_t *b;
b = NULL;
/*
* 1024 bytes should already be available, so this call does
* nothing.
*/
ATF_REQUIRE(b != NULL);
/*
* This call should grow it to 2048 bytes as only 1024 bytes are
* available in the buffer.
*/
ATF_REQUIRE(b != NULL);
/*
* 2048 bytes should already be available, so this call does
* nothing.
*/
ATF_REQUIRE(b != NULL);
/*
* This call should grow it to 4096 bytes as only 2048 bytes are
* available in the buffer.
*/
ATF_REQUIRE(b != NULL);
/* Consume some of the buffer so we can run the next test. */
isc_buffer_add(b, 4096);
/*
* This call should fail and leave buffer untouched.
*/
ATF_REQUIRE(b != NULL);
isc_buffer_free(&b);
isc_test_end();
}
}
isc_buffer_t *b;
b = NULL;
ATF_REQUIRE(b != NULL);
ATF_REQUIRE(b != NULL);
ATF_REQUIRE(b != NULL);
isc_buffer_free(&b);
isc_test_end();
}
}
isc_buffer_t *b;
int i;
b = NULL;
ATF_REQUIRE(b != NULL);
isc_buffer_putuint8(b, 1);
for (i = 0; i < 1000; i++) {
isc_buffer_putstr(b, "thisisa24charslongstring");
}
for (i = 0; i < 10000; i++) {
isc_buffer_putuint8(b, 1);
}
for (i = 0; i < 10000; i++) {
isc_buffer_putuint16(b, 1);
}
for (i = 0; i < 10000; i++) {
isc_buffer_putuint24(b, 1);
}
for (i = 0; i < 10000; i++) {
isc_buffer_putuint32(b, 1);
}
isc_buffer_free(&b);
isc_test_end();
}
/*
* Main
*/
ATF_TP_ADD_TCS(tp) {
return (atf_no_error());
}