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/tcpsocket.cpp | 73 ------------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 src/tests/tcpsocket.cpp (limited to 'src/tests/tcpsocket.cpp') diff --git a/src/tests/tcpsocket.cpp b/src/tests/tcpsocket.cpp deleted file mode 100644 index 89c015c..0000000 --- a/src/tests/tcpsocket.cpp +++ /dev/null @@ -1,73 +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 -#include - -#include -#include - -using namespace Bu; - -bool isUp() -{ - try - { - TcpSocket s("xagasoft.com", 9898, 1 ); - - char buf[5]; - buf[s.read(buf, 2, 1, 0)] = '\0'; - - if( !strcmp( buf, "hi" ) ) - return true; - else - return false; - } - catch(...) - { - return false; - } -} - -int main() -{ - uint32_t uUp = 0; - uint32_t uDown = 0; - uint32_t uTotal = 0; - struct timeval tv; - - for(;;) - { - gettimeofday( &tv, NULL ); - time_t goal = ((tv.tv_sec/5)+1)*5; - tv.tv_sec = goal-tv.tv_sec; - tv.tv_usec = 0-tv.tv_usec; - if( tv.tv_usec < 0 ) - { - tv.tv_sec--; - tv.tv_usec = 1000000+tv.tv_usec; - } - select( 0, NULL, NULL, NULL, &tv ); - gettimeofday( &tv, NULL ); - if( isUp() ) - { - uUp++; - sio << "status: up "; - } - else - { - uDown++; - sio << "status: down "; - } - uTotal++; - - sio << "(up=" << (uUp*5) << "s, down=" << (uDown*5) << ") up for " - << uUp*100/uTotal << "% of " << uTotal*5 << "s" << sio.nl - << sio.flush; - } -} - -- cgit v1.2.3