/*
SSSD
test_iobuf - IO buffer tests
Copyright (C) 2016 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include "util/sss_iobuf.h"
{
/* There is enough data in the buffer */
/* The data matches beginning of the buffer */
/* There is enough data in the buffer */
/* The data matches beginning of the buffer */
/* Try to read more than the buffer has */
/* This is not a fatal error */
/* We just see how much there was */
/* And get the rest of the buffer back. readbuf includes trailing zero now */
/* Reading a depleted buffer will just yield zero bytes read now */
assert_int_equal(nread, 0);
/* Failure cases */
}
{
/* Exactly fill the capacity */
sizeof("Hello world"));
/* Overflow the capacity by one */
sizeof("Hello world!"));
/* Test resizing exactly up to capacity in several writes */
sizeof("Hello ")-1); /* Not the null byte now.. */
sizeof("world"));
/* Overflow the capacity during a resize by one */
sizeof("Hello ")-1); /* Not the null byte now.. */
sizeof("world!"));
/* Test allocating an unlimited buffer */
sizeof("Hello ")-1); /* Not the null byte now.. */
sizeof("world"));
}
int main(void)
{
};
}