From 4b9289cfb260f4bcecaf23a810584ef6ef8e8501 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 30 Mar 2011 22:33:41 +0000 Subject: Ok, string stuff is working much, much better, a load of new unit tests have been added, and I deleted a whole slew of stupid old tests that I don't need. --- src/tests/rot13.cpp | 91 ----------------------------------------------------- 1 file changed, 91 deletions(-) delete mode 100644 src/tests/rot13.cpp (limited to 'src/tests/rot13.cpp') diff --git a/src/tests/rot13.cpp b/src/tests/rot13.cpp deleted file mode 100644 index 1530af3..0000000 --- a/src/tests/rot13.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2007-2011 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 "bu/protocol.h" -#include "bu/multiserver.h" -#include "bu/client.h" -#include "bu/filter.h" - -using namespace Bu; - -class Rot13Filter : public Filter -{ -public: - Rot13Filter( Stream &next ) : - Filter( next ) - { - } - - virtual ~Rot13Filter() - { - } - - virtual void start() - { - } - - virtual Bu::size stop() - { - return 0; - } - - virtual Bu::size read( void *pBuf, Bu::size nBytes ) - { - return rNext.read( pBuf, nBytes ); - } - - virtual Bu::size write( const void *pBuf, Bu::size nBytes ) - { - const char *cBuf = (const char *)pBuf; - char *buf = new char[nBytes]; - for( Bu::size j = 0; j < nBytes; j++ ) - { - if( cBuf[j] >= 'a' && cBuf[j] <= 'z' ) - buf[j] = (cBuf[j]-'a'+13)%26+'a'; - else if( cBuf[j] >= 'A' && cBuf[j] <= 'Z' ) - buf[j] = (cBuf[j]-'A'+13)%26+'A'; - else - buf[j] = cBuf[j]; - } - rNext.write( buf, nBytes ); - delete[] buf; - return nBytes; - } -}; - -class Rot13Protocol : public Protocol -{ -public: - void onNewConnection( Bu::Client *pClient ) - { - pClient->pushFilter(); - } - - void onNewData( Bu::Client *pClient ) - { - char buf[1024]; - while( pClient->hasInput() ) - { - int iAmnt = pClient->read( buf, 1024 ); - pClient->write( buf, iAmnt ); - } - } -}; - -int main() -{ - MultiServer xSrv; - - xSrv.setTimeout( 5 ); - xSrv.addProtocol( genProtocol, 9999 ); - - for(;;) - xSrv.scan(); - - return 0; -} - -- cgit v1.2.3