aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/formatter.cpp6
-rw-r--r--src/unit/variant.unit27
2 files changed, 31 insertions, 2 deletions
diff --git a/src/formatter.cpp b/src/formatter.cpp
index 17fb311..61a059a 100644
--- a/src/formatter.cpp
+++ b/src/formatter.cpp
@@ -351,7 +351,8 @@ Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::String &sStr )
351 351
352Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed char c ) 352Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed char c )
353{ 353{
354 f.write( (char *)&c, 1 ); 354 f.ifmt<signed char>( c );
355 //f.write( (char *)&c, 1 );
355 return f; 356 return f;
356} 357}
357 358
@@ -363,7 +364,8 @@ Bu::Formatter &Bu::operator<<( Bu::Formatter &f, char c )
363 364
364Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned char c ) 365Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned char c )
365{ 366{
366 f.write( (char *)&c, 1 ); 367 f.ifmt<unsigned char>( c );
368 //f.write( (char *)&c, 1 );
367 return f; 369 return f;
368} 370}
369 371
diff --git a/src/unit/variant.unit b/src/unit/variant.unit
index 1654c4f..4fd5e26 100644
--- a/src/unit/variant.unit
+++ b/src/unit/variant.unit
@@ -10,6 +10,18 @@
10#include "bu/membuf.h" 10#include "bu/membuf.h"
11#include "bu/formatter.h" 11#include "bu/formatter.h"
12#include "bu/string.h" 12#include "bu/string.h"
13#include "bu/sio.h"
14
15using namespace Bu;
16
17Bu::String mkastring()
18{
19 Bu::String a = "s";
20 a += "tu";
21 a += "f";
22 a += "f";
23 return a;
24}
13 25
14suite Variant 26suite Variant
15{ 27{
@@ -29,6 +41,21 @@ suite Variant
29 Bu::Formatter f( mb ); 41 Bu::Formatter f( mb );
30 f << v; 42 f << v;
31 unitTest( mb.getString() == v.get<Bu::String>() ); 43 unitTest( mb.getString() == v.get<Bu::String>() );
44 }
32 45
46 test stringForamtting
47 {
48 Bu::String s1;
49 s1 = "hello";
50 int32_t i1, i2;
51 i1 = 32;
52 i2 = 0;
53 Bu::String out = Bu::String("%1-%2-%3-%4.odp").
54 arg( s1.getStr() ).
55 arg( mkastring().getStr() ).
56 arg( i1, Fmt(2).fill('0') ).
57 arg( i2, Fmt(2).fill('0') );
58 sio << sio.nl << out << sio.nl;
59 unitTest( out == "hello-stuff-32-00.odp" );
33 } 60 }
34} 61}