summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-03-19 18:28:10 +0000
committerMike Buland <eichlan@xagasoft.com>2011-03-19 18:28:10 +0000
commitd223fcaba3660e8c4d61c9136311064898e23ae9 (patch)
tree58ac992b15667d814ddfd502640a54a1209e241e /src/tests
parentcba6293cf22e2c2ae17dd3954ad7d097f379c7ac (diff)
downloadlibbu++-d223fcaba3660e8c4d61c9136311064898e23ae9.tar.gz
libbu++-d223fcaba3660e8c4d61c9136311064898e23ae9.tar.bz2
libbu++-d223fcaba3660e8c4d61c9136311064898e23ae9.tar.xz
libbu++-d223fcaba3660e8c4d61c9136311064898e23ae9.zip
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.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cache.cpp19
-rw-r--r--src/tests/fastcgi.cpp8
-rw-r--r--src/tests/fstrformat.cpp19
-rw-r--r--src/tests/heap.cpp3
4 files changed, 11 insertions, 38 deletions
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:
105 Bu::File f( sFile, 105 Bu::File f( sFile,
106 Bu::File::Write|Bu::File::Create|Bu::File::Truncate 106 Bu::File::Write|Bu::File::Create|Bu::File::Truncate
107 ); 107 );
108 Bu::String s; 108 f.write( Bu::String("%1").arg( num ) );
109 s.format("%d", num );
110 f.write( s );
111 } 109 }
112 110
113 virtual void sync( Bob *, const long & ) 111 virtual void sync( Bob *, const long & )
@@ -126,16 +124,14 @@ public:
126 virtual Bob *load( const long &key ) 124 virtual Bob *load( const long &key )
127 { 125 {
128 TRACE( key ); 126 TRACE( key );
129 Bu::String sDest; 127 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
130 sDest.format("bobcache/%d", key );
131 return new Bob( readNum( sDest ) ); 128 return new Bob( readNum( sDest ) );
132 } 129 }
133 130
134 virtual void unload( Bob *pObj, const long &key ) 131 virtual void unload( Bob *pObj, const long &key )
135 { 132 {
136 TRACE( pObj, key ); 133 TRACE( pObj, key );
137 Bu::String sDest; 134 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
138 sDest.format("bobcache/%d", key );
139 writeNum( sDest, pObj->getInt() ); 135 writeNum( sDest, pObj->getInt() );
140 delete pObj; 136 delete pObj;
141 } 137 }
@@ -144,8 +140,7 @@ public:
144 { 140 {
145 TRACE( rSrc ); 141 TRACE( rSrc );
146 long id = ++cLastId; 142 long id = ++cLastId;
147 Bu::String sDest; 143 Bu::String sDest = Bu::String("bobcache/%1").arg( id );
148 sDest.format("bobcache/%d", id );
149 writeNum( sDest, rSrc->getInt() ); 144 writeNum( sDest, rSrc->getInt() );
150 return id; 145 return id;
151 } 146 }
@@ -153,8 +148,7 @@ public:
153 virtual void destroy( Bob *pObj, const long &key ) 148 virtual void destroy( Bob *pObj, const long &key )
154 { 149 {
155 TRACE( pObj, key ); 150 TRACE( pObj, key );
156 Bu::String sDest; 151 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
157 sDest.format("bobcache/%d", key );
158 if( !access( sDest.getStr(), F_OK ) ) 152 if( !access( sDest.getStr(), F_OK ) )
159 unlink( sDest.getStr() ); 153 unlink( sDest.getStr() );
160 delete pObj; 154 delete pObj;
@@ -163,8 +157,7 @@ public:
163 virtual void destroy( const long &key ) 157 virtual void destroy( const long &key )
164 { 158 {
165 TRACE( pObj, key ); 159 TRACE( pObj, key );
166 Bu::String sDest; 160 Bu::String sDest = Bu::String("bobcache/%1").arg( key );
167 sDest.format("bobcache/%d", key );
168 if( !access( sDest.getStr(), F_OK ) ) 161 if( !access( sDest.getStr(), F_OK ) )
169 unlink( sDest.getStr() ); 162 unlink( sDest.getStr() );
170 } 163 }
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:
43 sOut += getcwd( buf, 2048 ); 43 sOut += getcwd( buf, 2048 );
44 sOut += "</li></ul>"; 44 sOut += "</li></ul>";
45 sOut += "<h1>Stdin:</h1>"; 45 sOut += "<h1>Stdin:</h1>";
46 sOut.formatAppend("%d bytes<pre>", sStdIn.getSize() ); 46 sOut += Bu::String("%1 bytes<pre>").arg( sStdIn.getSize() );
47 Bu::String sL, sR; 47 Bu::String sL, sR;
48 for( Bu::String::const_iterator i = sStdIn.begin(); 48 for( Bu::String::const_iterator i = sStdIn.begin();
49 i; i++ ) 49 i; i++ )
50 { 50 {
51 sL.formatAppend("%02X ", 51 sL += Bu::String("%1").arg(
52 (unsigned int)((unsigned char)*i) ); 52 (unsigned int)((unsigned char)*i), Bu::Fmt::hex().width(2).fill('0') );
53 if( *i < 27 ) 53 if( *i < 27 )
54 sR += ". "; 54 sR += ". ";
55 else 55 else
56 sR.formatAppend("&#%d; ", 56 sR += Bu::String("&#%1; ").arg(
57 (unsigned int)((unsigned char)*i) ); 57 (unsigned int)((unsigned char)*i) );
58 if( sL.getSize()/3 == 8 ) 58 if( sL.getSize()/3 == 8 )
59 { 59 {
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 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/string.h"
9#include <stdio.h>
10
11int main()
12{
13 Bu::String s;
14
15 s.format("%d, %f, \'%s\'", 144, 12.5, "bob" );
16
17 printf("test: %s\n", s.getStr() );
18}
19
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
41void printHeap( Bu::Heap<Bu::String> &h, int j ) 41void printHeap( Bu::Heap<Bu::String> &h, int j )
42{ 42{
43// return; 43// return;
44 Bu::String sFName; 44 Bu::String sFName = Bu::String("graph-step-%1.dot").arg( j, Bu::Fmt().width(2).fill('0') );
45 sFName.format("graph-step-%02d.dot", j );
46 Bu::File fOut( sFName, Bu::File::WriteNew ); 45 Bu::File fOut( sFName, Bu::File::WriteNew );
47 Bu::Formatter f( fOut ); 46 Bu::Formatter f( fOut );
48 f << "Graph step: " << j << ", total size: " << h.getSize() << f.nl; 47 f << "Graph step: " << j << ", total size: " << h.getSize() << f.nl;