aboutsummaryrefslogtreecommitdiff
path: root/src/tools/mkunit.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
commit393f1b414746a7f1977971dd7659dd2b47092b11 (patch)
tree81d0ca1ee70ab86a7d79c1991abe5c387b655fb2 /src/tools/mkunit.cpp
parentc259f95bd0e58b247940a339bb9b4b401b4e9438 (diff)
parent7e25a863325dc3e9762397e700030969e093b087 (diff)
downloadlibbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.gz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.bz2
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.xz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.zip
Wow! Merged the branch, streams are updated, and there's no more FString, run
the fixstrings.sh script in the support directory to (hopefully) automatically update your projects.
Diffstat (limited to 'src/tools/mkunit.cpp')
-rw-r--r--src/tools/mkunit.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/tools/mkunit.cpp b/src/tools/mkunit.cpp
index 12ce65f..741a888 100644
--- a/src/tools/mkunit.cpp
+++ b/src/tools/mkunit.cpp
@@ -1,3 +1,10 @@
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
1#include <bu/file.h> 8#include <bu/file.h>
2#include <bu/optparser.h> 9#include <bu/optparser.h>
3#include <bu/buffer.h> 10#include <bu/buffer.h>
@@ -15,7 +22,7 @@ public:
15 { 22 {
16 } 23 }
17 24
18 Bu::FString sName; 25 Bu::String sName;
19 bool bExpectPass; 26 bool bExpectPass;
20}; 27};
21typedef Bu::List<Test> TestList; 28typedef Bu::List<Test> TestList;
@@ -23,7 +30,7 @@ typedef Bu::List<Test> TestList;
23class Suite 30class Suite
24{ 31{
25public: 32public:
26 Bu::FString sName; 33 Bu::String sName;
27 TestList lTest; 34 TestList lTest;
28}; 35};
29//typedef Bu::List<Suite> SuiteList; 36//typedef Bu::List<Suite> SuiteList;
@@ -66,7 +73,7 @@ Bu::Formatter &operator<<( Bu::Formatter &f, const Suite &s )
66class Parser 73class Parser
67{ 74{
68public: 75public:
69 Parser( const Bu::FString &sFile ) : 76 Parser( const Bu::String &sFile ) :
70 sIn( sFile ), 77 sIn( sFile ),
71 fIn( sFile, File::Read ), 78 fIn( sFile, File::Read ),
72 bIn( fIn ), 79 bIn( fIn ),
@@ -99,10 +106,10 @@ public:
99 return cBuf; 106 return cBuf;
100 } 107 }
101 108
102 TokType nextToken( Variant &v, Bu::FString &sWsOut, int &iLineStart, 109 TokType nextToken( Variant &v, Bu::String &sWsOut, int &iLineStart,
103 int &iCharStart ) 110 int &iCharStart )
104 { 111 {
105 Bu::FString sTok, sWs; 112 Bu::String sTok, sWs;
106 113
107 char buf; 114 char buf;
108 try 115 try
@@ -307,7 +314,7 @@ public:
307 void firstPass() 314 void firstPass()
308 { 315 {
309 Variant v; 316 Variant v;
310 Bu::FString sWs; 317 Bu::String sWs;
311 int iL, iC; 318 int iL, iC;
312 for(;;) 319 for(;;)
313 { 320 {
@@ -322,7 +329,7 @@ public:
322 if( nextToken( v, sWs, iL, iC ) != tokFluff ) 329 if( nextToken( v, sWs, iL, iC ) != tokFluff )
323 throw Bu::ExceptionBase("%d:%d: Expected string " 330 throw Bu::ExceptionBase("%d:%d: Expected string "
324 "following suite.", iL, iC ); 331 "following suite.", iL, iC );
325 s.sName = v.get<Bu::FString>(); 332 s.sName = v.get<Bu::String>();
326 if( nextToken( v, sWs, iL, iC ) != tokChar || 333 if( nextToken( v, sWs, iL, iC ) != tokChar ||
327 v.get<char>() != '{' ) 334 v.get<char>() != '{' )
328 throw Bu::ExceptionBase("%d:%d: Expected {, got " 335 throw Bu::ExceptionBase("%d:%d: Expected {, got "
@@ -346,7 +353,7 @@ public:
346 throw Bu::ExceptionBase("%d:%d: Expected " 353 throw Bu::ExceptionBase("%d:%d: Expected "
347 "string following test.", iL, iC ); 354 "string following test.", iL, iC );
348 Test t; 355 Test t;
349 t.sName = v.get<Bu::FString>(); 356 t.sName = v.get<Bu::String>();
350 if( nextToken( v, sWs, iL, iC ) != tokBlock ) 357 if( nextToken( v, sWs, iL, iC ) != tokBlock )
351 throw Bu::ExceptionBase("%d:%d: Expected " 358 throw Bu::ExceptionBase("%d:%d: Expected "
352 "{...} block.", 359 "{...} block.",
@@ -380,7 +387,7 @@ public:
380 } 387 }
381 } 388 }
382 389
383 void secondPass( const Bu::FString &sOut ) 390 void secondPass( const Bu::String &sOut )
384 { 391 {
385 File fOut( sOut, File::WriteNew ); 392 File fOut( sOut, File::WriteNew );
386 Formatter f( fOut ); 393 Formatter f( fOut );
@@ -393,7 +400,7 @@ public:
393 iChar = 0; 400 iChar = 0;
394 bool bHasIncluded = false; 401 bool bHasIncluded = false;
395 402
396 Bu::FString sWs; 403 Bu::String sWs;
397 Variant v; 404 Variant v;
398 int iL, iC; 405 int iL, iC;
399 for(;;) 406 for(;;)
@@ -408,7 +415,7 @@ public:
408 if( nextToken( v, sWs, iL, iC ) != tokFluff ) 415 if( nextToken( v, sWs, iL, iC ) != tokFluff )
409 throw Bu::ExceptionBase("%d:%d: Expected string " 416 throw Bu::ExceptionBase("%d:%d: Expected string "
410 "following suite.", iL, iC ); 417 "following suite.", iL, iC );
411 s.sName = v.get<Bu::FString>(); 418 s.sName = v.get<Bu::String>();
412 if( nextToken( v, sWs, iL, iC ) != tokChar || 419 if( nextToken( v, sWs, iL, iC ) != tokChar ||
413 v.get<char>() != '{' ) 420 v.get<char>() != '{' )
414 throw Bu::ExceptionBase("%d:%d: Expected {", 421 throw Bu::ExceptionBase("%d:%d: Expected {",
@@ -421,7 +428,7 @@ public:
421 bHasIncluded = true; 428 bHasIncluded = true;
422 } 429 }
423 430
424 Bu::FString sClass = "_UnitSuite_" + s.sName; 431 Bu::String sClass = "_UnitSuite_" + s.sName;
425 f << "class " << sClass 432 f << "class " << sClass
426 << " : public Bu::UnitSuite" << f.nl 433 << " : public Bu::UnitSuite" << f.nl
427 << "{" << f.nl << "public:" << f.nl 434 << "{" << f.nl << "public:" << f.nl
@@ -441,7 +448,7 @@ public:
441 } 448 }
442 else if( t == tokEof ) 449 else if( t == tokEof )
443 { 450 {
444 Bu::FString sClass = "_UnitSuite_" + s.sName; 451 Bu::String sClass = "_UnitSuite_" + s.sName;
445 f << sWs << f.nl << "int main( int argc, char *argv[] )" 452 f << sWs << f.nl << "int main( int argc, char *argv[] )"
446 << f.nl << "{" << f.nl << "\treturn " << sClass 453 << f.nl << "{" << f.nl << "\treturn " << sClass
447 << "().run( argc, argv );" << f.nl << "}" << f.nl; 454 << "().run( argc, argv );" << f.nl << "}" << f.nl;
@@ -458,7 +465,7 @@ public:
458 { 465 {
459 case tokFluff: 466 case tokFluff:
460 fOut.write( sWs ); 467 fOut.write( sWs );
461 fOut.write( v.get<Bu::FString>() ); 468 fOut.write( v.get<Bu::String>() );
462 break; 469 break;
463 470
464 case tokTest: 471 case tokTest:
@@ -468,7 +475,7 @@ public:
468 throw Bu::ExceptionBase("%d:%d: Expected " 475 throw Bu::ExceptionBase("%d:%d: Expected "
469 "string following test.", iL, iC ); 476 "string following test.", iL, iC );
470 Test t; 477 Test t;
471 t.sName = v.get<Bu::FString>(); 478 t.sName = v.get<Bu::String>();
472 if( nextToken( v, sWs, iL, iC ) != tokBlock ) 479 if( nextToken( v, sWs, iL, iC ) != tokBlock )
473 throw Bu::ExceptionBase("%d:%d: Expected " 480 throw Bu::ExceptionBase("%d:%d: Expected "
474 "{...} block.", 481 "{...} block.",
@@ -499,7 +506,7 @@ public:
499 fOut.write( sWs ); 506 fOut.write( sWs );
500 f << f.nl << "#line " << iL << " \"" << sIn 507 f << f.nl << "#line " << iL << " \"" << sIn
501 << "\"" << f.nl; 508 << "\"" << f.nl;
502 fOut.write( v.get<Bu::FString>() ); 509 fOut.write( v.get<Bu::String>() );
503 510
504 break; 511 break;
505 512
@@ -521,7 +528,7 @@ public:
521 } 528 }
522 529
523private: 530private:
524 Bu::FString sIn; 531 Bu::String sIn;
525 File fIn; 532 File fIn;
526 Buffer bIn; 533 Buffer bIn;
527 char cBuf; 534 char cBuf;