From d223fcaba3660e8c4d61c9136311064898e23ae9 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 19 Mar 2011 18:28:10 +0000 Subject: The rest of libbu++ is corrected as far as the now Bu::String toUpper/toLower semantics go as well as switching everything to the new string formatting code. --- src/tests/cache.cpp | 19 ++++++------------- src/tests/fastcgi.cpp | 8 ++++---- src/tests/fstrformat.cpp | 19 ------------------- src/tests/heap.cpp | 3 +-- 4 files changed, 11 insertions(+), 38 deletions(-) delete mode 100644 src/tests/fstrformat.cpp (limited to 'src/tests') diff --git a/src/tests/cache.cpp b/src/tests/cache.cpp index 243012d..e9dbd86 100644 --- a/src/tests/cache.cpp +++ b/src/tests/cache.cpp @@ -105,9 +105,7 @@ public: Bu::File f( sFile, Bu::File::Write|Bu::File::Create|Bu::File::Truncate ); - Bu::String s; - s.format("%d", num ); - f.write( s ); + f.write( Bu::String("%1").arg( num ) ); } virtual void sync( Bob *, const long & ) @@ -126,16 +124,14 @@ public: virtual Bob *load( const long &key ) { TRACE( key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); return new Bob( readNum( sDest ) ); } virtual void unload( Bob *pObj, const long &key ) { TRACE( pObj, key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); writeNum( sDest, pObj->getInt() ); delete pObj; } @@ -144,8 +140,7 @@ public: { TRACE( rSrc ); long id = ++cLastId; - Bu::String sDest; - sDest.format("bobcache/%d", id ); + Bu::String sDest = Bu::String("bobcache/%1").arg( id ); writeNum( sDest, rSrc->getInt() ); return id; } @@ -153,8 +148,7 @@ public: virtual void destroy( Bob *pObj, const long &key ) { TRACE( pObj, key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); if( !access( sDest.getStr(), F_OK ) ) unlink( sDest.getStr() ); delete pObj; @@ -163,8 +157,7 @@ public: virtual void destroy( const long &key ) { TRACE( pObj, key ); - Bu::String sDest; - sDest.format("bobcache/%d", key ); + Bu::String sDest = Bu::String("bobcache/%1").arg( key ); if( !access( sDest.getStr(), F_OK ) ) unlink( sDest.getStr() ); } diff --git a/src/tests/fastcgi.cpp b/src/tests/fastcgi.cpp index 7ca4ebc..7447a6f 100644 --- a/src/tests/fastcgi.cpp +++ b/src/tests/fastcgi.cpp @@ -43,17 +43,17 @@ public: sOut += getcwd( buf, 2048 ); sOut += ""; sOut += "

Stdin:

"; - sOut.formatAppend("%d bytes
", sStdIn.getSize() );
+		sOut += Bu::String("%1 bytes
").arg( sStdIn.getSize() );
 		Bu::String sL, sR;
 		for( Bu::String::const_iterator i = sStdIn.begin();
 			i; i++ )
 		{
-			sL.formatAppend("%02X ",
-				(unsigned int)((unsigned char)*i) );
+			sL += Bu::String("%1").arg(
+					(unsigned int)((unsigned char)*i), Bu::Fmt::hex().width(2).fill('0') );
 			if( *i < 27 )
 				sR += ". ";
 			else
-				sR.formatAppend("&#%d; ",
+				sR += Bu::String("&#%1; ").arg(
 					(unsigned int)((unsigned char)*i) );
 			if( sL.getSize()/3 == 8 )
 			{
diff --git a/src/tests/fstrformat.cpp b/src/tests/fstrformat.cpp
deleted file mode 100644
index a911a8f..0000000
--- a/src/tests/fstrformat.cpp
+++ /dev/null
@@ -1,19 +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/string.h"
-#include 
-
-int main()
-{
-	Bu::String s;
-
-	s.format("%d, %f, \'%s\'", 144, 12.5, "bob" );
-
-	printf("test:  %s\n", s.getStr() );
-}
-
diff --git a/src/tests/heap.cpp b/src/tests/heap.cpp
index 14da55a..520a57f 100644
--- a/src/tests/heap.cpp
+++ b/src/tests/heap.cpp
@@ -41,8 +41,7 @@ typedef struct num
 void printHeap( Bu::Heap &h, int j )
 {
 //	return;
-	Bu::String sFName;
-	sFName.format("graph-step-%02d.dot", j );
+	Bu::String sFName = Bu::String("graph-step-%1.dot").arg( j, Bu::Fmt().width(2).fill('0') );
 	Bu::File fOut( sFName, Bu::File::WriteNew );
 	Bu::Formatter f( fOut );
 	f << "Graph step: " << j << ", total size: " << h.getSize() << f.nl;
-- 
cgit v1.2.3