From 093ef85e95d1b37e4a87ffc2a51433b2f1ed24e0 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 13 May 2010 19:23:43 +0000 Subject: david - put a bunch of data through it and check its validity --- src/unit/queuebuf.unit | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/unit/queuebuf.unit (limited to 'src/unit/queuebuf.unit') diff --git a/src/unit/queuebuf.unit b/src/unit/queuebuf.unit new file mode 100644 index 0000000..9ae7d36 --- /dev/null +++ b/src/unit/queuebuf.unit @@ -0,0 +1,104 @@ +// vim: syntax=cpp +/* + * Copyright (C) 2007-2010 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include +#include + +#include "bu/queuebuf.h" +#include "bu/md5.h" + +#define RNDCHR ((char)(((double)random()/(double)RAND_MAX)*256.0)) + +{=Init} + +{%testBasic01} +{ + Bu::QueueBuf qb; + unitTest( qb.write("ab", 2 ) == 2 ); + unitTest( qb.write("cde", 3 ) == 3 ); + unitTest( qb.write("FG", 2 ) == 2 ); + + char buf[8]; + buf[7] = '\0'; + unitTest( qb.read( buf, 7 ) == 7 ); + unitTest( !strncmp( buf, "abcdeFG", 7 ) ); + unitTest( qb.read( buf, 7 ) == 0 ); +} + +void QBUF_RANDSTR( Bu::FString &fill, unsigned int iSize ) +{ + char c; + for( unsigned int i=0; i