MsgFormatValidate Class Reference

#include <MsgFormatValidate.h>

List of all members.

Public Member Functions

 MsgFormatValidate ()
 ~MsgFormatValidate ()
bool RunAllTests ()

Private Member Functions

bool TestConstructors (int verbosity=VERBOSE)
bool TestManipulators (int verbosity=VERBOSE)
bool TestMsgBoundFormat ()

Detailed Description

Definition at line 16 of file MsgFormatValidate.h.


Constructor & Destructor Documentation

MsgFormatValidate::MsgFormatValidate (  ) 

Definition at line 20 of file MsgFormatValidate.cxx.

00020 {}

MsgFormatValidate::~MsgFormatValidate (  ) 

Definition at line 24 of file MsgFormatValidate.cxx.

00024 {}


Member Function Documentation

bool MsgFormatValidate::RunAllTests ( void   ) 

Definition at line 27 of file MsgFormatValidate.cxx.

References TestConstructors(), and TestManipulators().

Referenced by main(), and MsgServiceValidate::RunAllTests().

00028 {
00029   cout << "Testing MessageService formatting functions...\n"; 
00030   cout << "-------------------------------------------------------------\n";
00031   bool passed = true;
00032   passed &= this->TestConstructors();
00033   passed &= this->TestManipulators();
00034   cout << "-------------------------------------------------------------\n";
00035   cout << "testing complete.\n";
00036   return passed;
00037 }

bool MsgFormatValidate::TestConstructors ( int  verbosity = VERBOSE  )  [private]

Definition at line 41 of file MsgFormatValidate.cxx.

References QUIET, REALLY_VERBOSE, STRBUF_LEN, and VERBOSE.

Referenced by RunAllTests().

00042 {
00043   int passed = 1;
00044   static MsgFormat defaultFormat;
00045   static MsgFormat preFormat(3);
00046   static MsgFormat prewidFormat(4, 7);
00047   static MsgFormat x8Format("Ox8");  
00048   static MsgFormat o12Format("Oo4");
00049   static MsgFormat f12p6Format("f12.6");
00050   static MsgFormat e12p6Format("e12.6");
00051   static MsgFormat lf12p6Format("f-12.6");
00052   static MsgFormat pf12p6Format("f+12.6");
00053 
00054   int    i = 123;
00055   double x = 0.123456789;
00056 
00057   stringstream strstrm;
00058   string       outstr;
00059   string       validstr;
00060   char         strbuf[STRBUF_LEN];
00061   
00062   cout << " ======= testing Constructors ========================\n";
00063 
00064 //======= Default constructor =============================================
00065   if(verbosity == REALLY_VERBOSE) {
00066   cout << "  Default                  : " 
00067        << "<" << defaultFormat(i) << "> <" << defaultFormat(x) << ">\n";
00068   }
00069   
00070   strstrm << "<" << defaultFormat(i) << "> <" << defaultFormat(x) << ">\n";
00071   strstrm.getline(strbuf, STRBUF_LEN);
00072 
00073   outstr = strbuf;
00074   validstr = "<123> <0.123457>";
00075 
00076   if(outstr == validstr){
00077     if( verbosity >= VERBOSE )
00078     cout << " default format constructor                     ok\n";
00079   }
00080   else{
00081     passed = 0;
00082     cout << " default format constructor                     error\n"
00083          << "valid:  " << validstr << endl
00084          << "actual: " << outstr   << endl;
00085   }
00086 
00087 //======= Precision constructor =============================================
00088   if(verbosity == REALLY_VERBOSE) {
00089   cout << "  Precision = 3            : " 
00090        << "<" << preFormat(i) << "> <" << preFormat(x) << ">\n";
00091   }
00092   
00093   strstrm << "<" << preFormat(i) << "> <" << preFormat(x) << ">\n";
00094   strstrm.getline(strbuf, STRBUF_LEN);
00095 
00096   outstr = strbuf;
00097   validstr = "<123> <0.123>";
00098 
00099   if(outstr == validstr){
00100     if( verbosity >= VERBOSE )
00101     cout << " precision format constructor                   ok\n";
00102   }
00103   else{
00104     passed = 0;
00105     cout << " precision format constructor                   error\n"
00106          << "Precision = 3" << endl
00107          << "valid:  " << validstr << endl
00108          << "actual: " << outstr   << endl;
00109   }
00110 
00111 //======= Precision and Width constructor ==================================
00112   if(verbosity == REALLY_VERBOSE) {
00113     cout << "  Precision = 4, Width = 7: " 
00114          << "<" << prewidFormat(i) << "> <" << prewidFormat(x) << ">\n";
00115   }
00116   
00117   strstrm << "<" << prewidFormat(i) << "> <" << prewidFormat(x) << ">\n";
00118   strstrm.getline(strbuf, STRBUF_LEN);
00119 
00120   outstr = strbuf;
00121   validstr = "<    123> < 0.1235>";
00122 
00123   if(outstr == validstr){
00124     if( verbosity >= VERBOSE )
00125     cout << " precision and width format constructor         ok\n";
00126   }
00127   else{
00128     passed = 0;
00129     cout << " precision and width format constructor         error\n"
00130          << "Precision = 3, Width = 7" << endl
00131          << "valid:  " << validstr << endl
00132          << "actual: " << outstr   << endl;
00133   }
00134 
00135 //======= Hex Format constructor =============================================
00136   if(verbosity == REALLY_VERBOSE) {
00137     cout << " x8     : "
00138          << "<" << x8Format(i) << "> <" << x8Format(x) << ">\n";
00139   }
00140   
00141   strstrm << "<" << x8Format(i) << "> <" << x8Format(x) << ">\n";
00142   strstrm.getline(strbuf, STRBUF_LEN);
00143 
00144   outstr = strbuf;
00145   validstr = "<0x7b0000> <00000000>";
00146 
00147   if(outstr == validstr){
00148     if( verbosity >= VERBOSE )
00149     cout << " hex format (x8) constructor                    ok\n";
00150   }
00151   else{
00152     passed = 0;
00153     cout << " hex format (x8) constructor                   error\n"
00154          << "valid:  " << validstr << endl
00155          << "actual: " << outstr   << endl;
00156   }
00157 
00158 //======= Octal Format constructor =============================================
00159   if(verbosity == REALLY_VERBOSE) {
00160     cout << " o12    : "
00161          << "<" << o12Format(i) << "> <" << o12Format(x) << ">\n";
00162   }
00163   
00164   strstrm << "<" << o12Format(i) << "> <" << o12Format(x) << ">\n";
00165   strstrm.getline(strbuf, STRBUF_LEN);
00166 
00167   outstr = strbuf;
00168   validstr = "<0173> <0000>";
00169 
00170   if(outstr == validstr){
00171     if( verbosity >= VERBOSE )
00172     cout << " octal format (o12) constructor                 ok\n";
00173   }
00174   else{
00175     passed = 0;
00176     cout << " octal format (o12) constructor:                error\n"
00177          << "valid:  " << validstr << endl
00178          << "actual: " << outstr   << endl;
00179   }
00180 
00181 //======= Float Format (f12.6) constructor =============================================
00182   if(verbosity == REALLY_VERBOSE) {
00183     cout << " f12.6  : " 
00184          << "<" << f12p6Format(i) << "> <" << f12p6Format(x) << ">\n";
00185   }
00186   
00187   strstrm << "<" << f12p6Format(i) << "> <" << f12p6Format(x) << ">\n";
00188   strstrm.getline(strbuf, STRBUF_LEN);
00189 
00190   outstr = strbuf;
00191   validstr = "<  123.000000> <    0.123457>";
00192 
00193   if(outstr == validstr){
00194     if( verbosity >= VERBOSE )
00195     cout << " float format (f12.6) constructor               ok\n";
00196   }
00197   else{
00198     passed = 0;
00199     cout << " float format (f12.6) constructor               error\n"
00200          << "valid:  " << validstr << endl
00201          << "actual: " << outstr   << endl;
00202   }
00203 
00204 //======= Exponent Format constructor =============================================
00205   if(verbosity == REALLY_VERBOSE) {
00206     cout << " e12.6  : " 
00207          << "<" << e12p6Format(i) << "> <" << e12p6Format(x) << ">\n";
00208   }
00209   
00210   strstrm << "<" << e12p6Format(i) << "> <" << e12p6Format(x) << ">\n";
00211   strstrm.getline(strbuf, STRBUF_LEN);
00212 
00213   outstr = strbuf;
00214   validstr = "<1.230000e+02> <1.234568e-01>";
00215 
00216   if(outstr == validstr){
00217     if( verbosity >= VERBOSE )
00218     cout << " exponent format (e12.6) constructor            ok\n";
00219   }
00220   else{
00221     passed = 0;
00222     cout << " exponent format (e12.6) constructor            error\n"
00223          << "valid:  " << validstr << endl
00224          << "actual: " << outstr   << endl;
00225   }
00226 
00227 //======= Left-aligned Float Format constructor ===============================
00228   if(verbosity == REALLY_VERBOSE) {
00229     cout << " f-12.6 : " 
00230          << "<" << lf12p6Format(i) << "> <" << lf12p6Format(x) << ">\n";
00231   }
00232   
00233   strstrm << "<" << lf12p6Format(i) << "> <" << lf12p6Format(x) << ">\n";
00234   strstrm.getline(strbuf, STRBUF_LEN);
00235 
00236   outstr = strbuf;
00237   validstr = "<123.000000  > <0.123457    >";
00238 
00239   if(outstr == validstr){
00240     if( verbosity >= VERBOSE )
00241     cout << " left-aligned float format (f-12.6) constructor ok\n";
00242   }
00243   else{
00244     passed = 0;
00245     cout << " left-aligned float format (f-12.6) constructor error\n"
00246          << "valid:  " << validstr << endl
00247          << "actual: " << outstr   << endl;
00248   }
00249 
00250 //======= Left aligned Float Format constructor =============================================
00251   if(verbosity == REALLY_VERBOSE) {
00252     cout << " f+12.6 : " 
00253          << "<" << pf12p6Format(i) << "> <" << pf12p6Format(x) << ">\n";
00254   }
00255   
00256   strstrm << "<" << pf12p6Format(i) << "> <" << pf12p6Format(x) << ">\n";
00257   strstrm.getline(strbuf, STRBUF_LEN);
00258 
00259   outstr = strbuf;
00260   validstr = "< +123.000000> <   +0.123457>";
00261 
00262   if(outstr == validstr){
00263     if( verbosity >= VERBOSE )
00264     cout << " signed float format (f-12.6) constructor       ok\n";
00265   }
00266   else{
00267     cout << " signed float format (f-12.6) constructor       error\n"
00268          << "valid:  " << validstr << endl
00269          << "actual: " << outstr   << endl;
00270   }
00271   
00272   if(verbosity == QUIET){
00273     if(passed) {
00274       cout << " Constructors ok.\n";
00275     } else {
00276       cout << " *** error(s) with constructors.\n";
00277     }
00278   }
00279   
00280   return passed;
00281 }

bool MsgFormatValidate::TestManipulators ( int  verbosity = VERBOSE  )  [private]

Definition at line 285 of file MsgFormatValidate.cxx.

References MsgFormat::fixed(), MsgFormat::general(), MsgFormat::hex(), MsgFormat::left_justify(), MsgFormat::oct(), MsgFormat::plus(), MsgFormat::precision(), QUIET, REALLY_VERBOSE, MsgFormat::scientific(), MsgFormat::show_base(), STRBUF_LEN, MsgFormat::trailing_zeros(), VERBOSE, and MsgFormat::width().

Referenced by RunAllTests().

00286 {
00287   int passed = 1;
00288   MsgFormat fmFixed;
00289   MsgFormat fmGeneral;
00290   MsgFormat fmHex;
00291   MsgFormat fmOct;
00292   MsgFormat fmScientific;
00293   int i1 = 8;
00294   int i2 = 1234; 
00295   double d1 = 0.123456789;
00296   double d2 = 123456789.0;
00297 
00298   fmFixed.fixed();
00299   fmGeneral.general();
00300   fmHex.hex();
00301   fmOct.oct();
00302   fmScientific.scientific();
00303   
00304   stringstream strstrm;
00305   string       outstr;
00306   string       validstr;
00307   char         strbuf[STRBUF_LEN];
00308   
00309   cout << " ======= testing Manipulators ========================\n";
00310 
00311   if(verbosity >= REALLY_VERBOSE)
00312   {
00313   cout << "     Fixed Format: " 
00314        << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00315        << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00316   cout << "   General Format: " 
00317        << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00318        << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00319   cout << "       Hex Format: " 
00320        << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00321   cout << "     Octal Format: " 
00322        << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00323   cout << "Scientific Format: " 
00324        << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00325        << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00326   }
00327 
00328 //======= Set Precision Manipulator ===========================================
00329   if(verbosity == REALLY_VERBOSE) {
00330   cout << "---- Set Precision 4 ------------------------------\n";
00331   }
00332 
00333 //------- precision manipulator for fixed format ------------------------------
00334   fmFixed.precision(4);
00335 
00336   if(verbosity == REALLY_VERBOSE) {
00337   cout << "     Fixed Format: " 
00338        << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00339        << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00340   }
00341   
00342   strstrm << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00343           << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00344   strstrm.getline(strbuf, STRBUF_LEN);
00345 
00346   outstr = strbuf;
00347   validstr = "<8.0000> <1234.0000> <0.1235> <123456789.0000>";
00348 
00349   if(outstr == validstr){
00350     if( verbosity >= REALLY_VERBOSE )
00351     cout << " precision manipulator for fixed format           ok\n";
00352   }
00353   else{
00354     passed = 0;
00355     cout << " precision manipulator for fixed format           error\n"
00356          << "valid:  " << validstr << endl
00357          << "actual: " << outstr   << endl;
00358   }
00359   
00360 //------- precision manipulator for general format ---------------------------
00361   fmGeneral.precision(4);
00362 
00363   if(verbosity == REALLY_VERBOSE) {
00364   cout << "   General Format: " 
00365        << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00366        << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00367   }
00368   
00369   strstrm << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00370           << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00371   strstrm.getline(strbuf, STRBUF_LEN);
00372 
00373   outstr = strbuf;
00374   validstr = "<8> <1234> <0.1235> <1.235e+08>";
00375 
00376   if(outstr == validstr){
00377     if( verbosity >= REALLY_VERBOSE )
00378     cout << " precision manipulator for general format         ok\n";
00379   }
00380   else{
00381     passed = 0;
00382     cout << " precision manipulator for general format         error\n"
00383          << "valid:  " << validstr << endl
00384          << "actual: " << outstr   << endl;
00385   }
00386 
00387 //------- precision manipulator for hex format --------------------------------
00388   fmHex.precision(4);
00389 
00390   if(verbosity == REALLY_VERBOSE) {
00391   cout << "       Hex Format: " 
00392        << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00393   }
00394   
00395   strstrm << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00396   strstrm.getline(strbuf, STRBUF_LEN);
00397 
00398   outstr = strbuf;
00399   validstr = "<8> <4d2>";
00400 
00401   if(outstr == validstr){
00402     if( verbosity >= REALLY_VERBOSE )
00403     cout << " precision manipulator for hex format             ok\n";
00404   }
00405   else{
00406     passed = 0;
00407     cout << " precision manipulator for hex format             error\n"
00408          << "valid:  " << validstr << endl
00409          << "actual: " << outstr   << endl;
00410   }
00411 
00412 //------- precision manipulator for octal format ------------------------------
00413   fmOct.precision(4);
00414 
00415   if(verbosity == REALLY_VERBOSE) {
00416   cout << "     Octal Format: " 
00417        << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00418   }
00419   
00420   strstrm << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00421   strstrm.getline(strbuf, STRBUF_LEN);
00422 
00423   outstr = strbuf;
00424   validstr = "<10> <2322>";
00425 
00426   if(outstr == validstr){
00427     if( verbosity >= REALLY_VERBOSE )
00428     cout << " precision manipulator for octal format           ok\n";
00429   }
00430   else{
00431     passed = 0;
00432     cout << " precision manipulator for octal format           error\n"
00433          << "valid:  " << validstr << endl
00434          << "actual: " << outstr   << endl;
00435   }
00436 
00437 //------- precision manipulator for scientific format --------------------------
00438   fmScientific.precision(4);
00439 
00440   if(verbosity == REALLY_VERBOSE) {
00441   cout << "Scientific Format: " 
00442        << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00443        << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00444   }
00445   
00446   strstrm << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00447           << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00448   strstrm.getline(strbuf, STRBUF_LEN);
00449 
00450   outstr = strbuf;
00451   validstr = "<8.0000e+00> <1.2340e+03> <1.2346e-01> <1.2346e+08>";
00452 
00453   if(outstr == validstr){
00454     if( verbosity >= REALLY_VERBOSE )
00455     cout << " precision manipulator for scientific format      ok\n";
00456   }
00457   else{
00458     passed = 0;
00459     cout << " precision manipulator for scientific format      error\n"
00460          << "valid:  " << validstr << endl
00461          << "actual: " << outstr   << endl;
00462   }
00463 
00464   if(verbosity == VERBOSE){
00465     if(passed) {
00466       cout << " precision manipulator      ok\n";
00467     } else {
00468       cout << " *** error(s) with precision manipulator.\n";
00469     }
00470   }
00471   passed = 1;
00472 
00473 //======= Set Width Manipulator ===========================================
00474   if(verbosity == REALLY_VERBOSE) {
00475   cout << "---- Set Width 8 ------------------------------\n";
00476   }
00477 
00478 //------- width manipulator for fixed format ------------------------------
00479   fmFixed.width(8);
00480 
00481   if(verbosity == REALLY_VERBOSE) {
00482   cout << "     Fixed Format: " 
00483        << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00484        << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00485   }
00486   
00487   strstrm << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00488           << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00489   strstrm.getline(strbuf, STRBUF_LEN);
00490 
00491   outstr = strbuf;
00492   validstr = "<  8.0000> <1234.0000> <  0.1235> <123456789.0000>";
00493 
00494   if(outstr == validstr){
00495     if( verbosity >= REALLY_VERBOSE )
00496     cout << " width manipulator for fixed format               ok\n";
00497   }
00498   else{
00499     passed = 0;
00500     cout << " width manipulator for fixed format               error\n"
00501          << "valid:  " << validstr << endl
00502          << "actual: " << outstr   << endl;
00503   }
00504 
00505 //------- width manipulator for general format ------------------------------
00506   fmGeneral.width(8);
00507 
00508   if(verbosity == REALLY_VERBOSE) {
00509   cout << "   General Format: " 
00510        << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00511        << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00512   }
00513   
00514   strstrm << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00515           << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00516   strstrm.getline(strbuf, STRBUF_LEN);
00517 
00518   outstr = strbuf;
00519   validstr = "<       8> <    1234> <  0.1235> <1.235e+08>";
00520 
00521   if(outstr == validstr){
00522     if( verbosity >= REALLY_VERBOSE )
00523     cout << " width manipulator for general format             ok\n";
00524   }
00525   else{
00526     passed = 0;
00527     cout << " width manipulator for general format             error\n"
00528          << "valid:  " << validstr << endl
00529          << "actual: " << outstr   << endl;
00530   }
00531   
00532 //------- width manipulator for hex format ------------------------------
00533   fmHex.width(8);
00534 
00535   if(verbosity == REALLY_VERBOSE) {
00536   cout << "       Hex Format: " 
00537        << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00538   }
00539   
00540   strstrm << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00541   strstrm.getline(strbuf, STRBUF_LEN);
00542 
00543   outstr = strbuf;
00544   validstr = "<       8> <     4d2>";
00545 
00546   if(outstr == validstr){
00547     if( verbosity >= REALLY_VERBOSE )
00548     cout << " width manipulator for hex format                 ok\n";
00549   }
00550   else{
00551     passed = 0;
00552     cout << " width manipulator for hex format                 error\n"
00553          << "valid:  " << validstr << endl
00554          << "actual: " << outstr   << endl;
00555   }
00556   
00557 //------- width manipulator for octal format ------------------------------
00558   fmOct.width(8);
00559 
00560   if(verbosity == REALLY_VERBOSE) {
00561   cout << "     Octal Format: " 
00562        << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00563   }
00564   
00565   strstrm << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00566   strstrm.getline(strbuf, STRBUF_LEN);
00567 
00568   outstr = strbuf;
00569   validstr = "<      10> <    2322>";
00570 
00571   if(outstr == validstr){
00572     if( verbosity >= REALLY_VERBOSE )
00573     cout << " width manipulator for octal format               ok\n";
00574   }
00575   else{
00576     passed = 0;
00577     cout << " width manipulator for octal format               error\n"
00578          << "valid:  " << validstr << endl
00579          << "actual: " << outstr   << endl;
00580   }
00581   
00582 //------- width manipulator for scientific format ------------------------------
00583   fmScientific.width(8);
00584 
00585   if(verbosity == REALLY_VERBOSE) {
00586   cout << "Scientific Format: " 
00587        << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00588        << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00589   }
00590   
00591   strstrm << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00592           << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00593   strstrm.getline(strbuf, STRBUF_LEN);
00594 
00595   outstr = strbuf;
00596   validstr = "<8.0000e+00> <1.2340e+03> <1.2346e-01> <1.2346e+08>";
00597 
00598   if(outstr == validstr){
00599     if( verbosity >= REALLY_VERBOSE )
00600     cout << " width manipulator for scientific format          ok\n";
00601   }
00602   else{
00603     passed = 0;
00604     cout << " width manipulator for scientific format          error\n"
00605          << "valid:  " << validstr << endl
00606          << "actual: " << outstr   << endl;
00607   }
00608   
00609   if(verbosity == VERBOSE){
00610     if(passed) {
00611       cout << " width manipulator          ok\n";
00612     } else {
00613       cout << " *** error(s) with width manipulator.\n";
00614     }
00615   }
00616   passed = 1;
00617 
00618 
00619 //======= Left Justify Manipulator ===========================================
00620   if(verbosity == REALLY_VERBOSE) {
00621   cout << "---- left justify ------------------------------\n";
00622   }
00623 
00624 //------- left_justify manipulator for fixed format ------------------------------
00625   fmFixed.left_justify();
00626 
00627   if(verbosity == REALLY_VERBOSE) {
00628   cout << "     Fixed Format: " 
00629        << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00630        << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00631   }
00632   
00633   strstrm << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00634           << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00635   strstrm.getline(strbuf, STRBUF_LEN);
00636 
00637   outstr = strbuf;
00638   validstr = "<8.0000  > <1234.0000> <0.1235  > <123456789.0000>";
00639 
00640   if(outstr == validstr){
00641     if( verbosity >= REALLY_VERBOSE )
00642     cout << " left_justify manipulator for fixed format        ok\n";
00643   }
00644   else{
00645     passed = 0;
00646     cout << " left_justify manipulator for fixed format        error\n"
00647          << "valid:  " << validstr << endl
00648          << "actual: " << outstr   << endl;
00649   }
00650 
00651 //------- left_justify manipulator for general format -------------------------
00652   fmGeneral.left_justify();
00653 
00654   if(verbosity == REALLY_VERBOSE) {
00655   cout << "   General Format: " 
00656        << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00657        << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00658   }
00659   
00660   strstrm << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00661           << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00662   strstrm.getline(strbuf, STRBUF_LEN);
00663 
00664   outstr = strbuf;
00665   validstr = "<8       > <1234    > <0.1235  > <1.235e+08>";
00666 
00667   if(outstr == validstr){
00668     if( verbosity >= REALLY_VERBOSE )
00669     cout << " left_justify manipulator for general format      ok\n";
00670   }
00671   else{
00672     passed = 0;
00673     cout << " left_justify manipulator for general format      error\n"
00674          << "valid:  " << validstr << endl
00675          << "actual: " << outstr   << endl;
00676   }
00677 
00678 //------- left_justify manipulator for hex format -------------------------
00679   fmHex.left_justify();
00680 
00681   if(verbosity == REALLY_VERBOSE) {
00682   cout << "       Hex Format: " 
00683        << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00684   }
00685   
00686   strstrm << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00687   strstrm.getline(strbuf, STRBUF_LEN);
00688 
00689   outstr = strbuf;
00690   validstr = "<8       > <4d2     >";
00691 
00692   if(outstr == validstr){
00693     if( verbosity >= REALLY_VERBOSE )
00694     cout << " left_justify manipulator for hex format          ok\n";
00695   }
00696   else{
00697     passed = 0;
00698     cout << " left_justify manipulator for hex format          error\n"
00699          << "valid:  " << validstr << endl
00700          << "actual: " << outstr   << endl;
00701   }
00702 
00703 //------- left_justify manipulator for octal format -------------------------
00704   fmOct.left_justify();
00705 
00706   if(verbosity == REALLY_VERBOSE) {
00707   cout << "     Octal Format: " 
00708        << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00709   }
00710   
00711   strstrm << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00712   strstrm.getline(strbuf, STRBUF_LEN);
00713 
00714   outstr = strbuf;
00715   validstr = "<10      > <2322    >";
00716 
00717   if(outstr == validstr){
00718     if( verbosity >= REALLY_VERBOSE )
00719     cout << " left_justify manipulator for octal format        ok\n";
00720   }
00721   else{
00722     passed = 0;
00723     cout << " left_justify manipulator for octal format        error\n"
00724          << "valid:  " << validstr << endl
00725          << "actual: " << outstr   << endl;
00726   }
00727 
00728 //------- left_justify manipulator for octal format -------------------------
00729   fmScientific.left_justify();
00730 
00731   if(verbosity == REALLY_VERBOSE) {
00732   cout << "Scientific Format: " 
00733        << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00734        << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00735   }
00736   
00737   strstrm << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00738           << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00739   strstrm.getline(strbuf, STRBUF_LEN);
00740 
00741   outstr = strbuf;
00742   validstr = "<8.0000e+00> <1.2340e+03> <1.2346e-01> <1.2346e+08>";
00743 
00744   if(outstr == validstr){
00745     if( verbosity >= REALLY_VERBOSE )
00746     cout << " left_justify manipulator for scientific format   ok\n";
00747   }
00748   else{
00749     passed = 0;
00750     cout << " left_justify manipulator for scientific format   error\n"
00751          << "valid:  " << validstr << endl
00752          << "actual: " << outstr   << endl;
00753   }
00754 
00755   if(verbosity == VERBOSE){
00756     if(passed) {
00757       cout << " left_justify manipulator   ok\n";
00758     } else {
00759       cout << " *** error(s) with left_justify manipulator.\n";
00760     }
00761   }
00762   passed = 1;
00763 
00764 // revert back to original justification
00765   fmFixed.left_justify(0);
00766   fmGeneral.left_justify(0);
00767   fmHex.left_justify(0);
00768   fmOct.left_justify(0);
00769   fmScientific.left_justify(0);
00770 
00771 
00772 //======= Show Base Manipulator ===========================================
00773   if(verbosity == REALLY_VERBOSE) {
00774   cout << "---- show base ----------------------------------\n";
00775   }
00776 
00777 //------- show_base manipulator for fixed format ------------------------------
00778   fmFixed.show_base();
00779 
00780   if(verbosity == REALLY_VERBOSE) {
00781   cout << "     Fixed Format: " 
00782        << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00783        << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00784   }
00785   
00786   strstrm << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00787           << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00788   strstrm.getline(strbuf, STRBUF_LEN);
00789 
00790   outstr = strbuf;
00791   validstr = "<  8.0000> <1234.0000> <  0.1235> <123456789.0000>";
00792 
00793   if(outstr == validstr){
00794     if( verbosity >= REALLY_VERBOSE )
00795     cout << " show_base manipulator for fixed format           ok\n";
00796   }
00797   else{
00798     passed = 0;
00799     cout << " show_base manipulator for fixed format        error\n"
00800          << "valid:  " << validstr << endl
00801          << "actual: " << outstr   << endl;
00802   }
00803 
00804 //------- show_base manipulator for general format ------------------------------
00805   fmGeneral.show_base();
00806 
00807   if(verbosity == REALLY_VERBOSE) {
00808   cout << "   General Format: " 
00809        << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00810        << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00811   }
00812   
00813   strstrm << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00814           << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00815   strstrm.getline(strbuf, STRBUF_LEN);
00816 
00817   outstr = strbuf;
00818   validstr = "<       8> <    1234> <  0.1235> <1.235e+08>";
00819 
00820   if(outstr == validstr){
00821     if( verbosity >= REALLY_VERBOSE )
00822     cout << " show_base manipulator for general format      ok\n";
00823   }
00824   else{
00825     passed = 0;
00826     cout << " show_base manipulator for general format      error\n"
00827          << "valid:  " << validstr << endl
00828          << "actual: " << outstr   << endl;
00829   }
00830 
00831 //------- show_base manipulator for hex format ------------------------------
00832   fmHex.show_base();
00833 
00834   if(verbosity == REALLY_VERBOSE) {
00835   cout << "       Hex Format: " 
00836        << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00837   }
00838   
00839   strstrm << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00840   strstrm.getline(strbuf, STRBUF_LEN);
00841 
00842   outstr = strbuf;
00843   validstr = "<     0x8> <   0x4d2>";
00844 
00845   if(outstr == validstr){
00846     if( verbosity >= REALLY_VERBOSE )
00847     cout << " show_base manipulator for hex format          ok\n";
00848   }
00849   else{
00850     passed = 0;
00851     cout << " show_base manipulator for hex format          error\n"
00852          << "valid:  " << validstr << endl
00853          << "actual: " << outstr   << endl;
00854   }
00855 
00856 //------- show_base manipulator for octal format ------------------------------
00857   fmOct.show_base();
00858 
00859   if(verbosity == REALLY_VERBOSE) {
00860   cout << "     Octal Format: " 
00861        << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00862   }
00863   
00864   strstrm << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
00865   strstrm.getline(strbuf, STRBUF_LEN);
00866 
00867   outstr = strbuf;
00868   validstr = "<     010> <   02322>";
00869 
00870   if(outstr == validstr){
00871     if( verbosity >= REALLY_VERBOSE )
00872     cout << " show_base manipulator for octal format        ok\n";
00873   }
00874   else{
00875     passed = 0;
00876     cout << " show_base manipulator for octal format        error\n"
00877          << "valid:  " << validstr << endl
00878          << "actual: " << outstr   << endl;
00879   }
00880 
00881 //------- show_base manipulator for scientific format -------------------------
00882   fmScientific.show_base();
00883 
00884   if(verbosity == REALLY_VERBOSE) {
00885   cout << "Scientific Format: " 
00886        << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00887        << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00888   }
00889   
00890   strstrm << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
00891           << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
00892   strstrm.getline(strbuf, STRBUF_LEN);
00893 
00894   outstr = strbuf;
00895   validstr = "<8.0000e+00> <1.2340e+03> <1.2346e-01> <1.2346e+08>";
00896 
00897   if(outstr == validstr){
00898     if( verbosity >= REALLY_VERBOSE )
00899     cout << " show_base manipulator for scientific format   ok\n";
00900   }
00901   else{
00902     passed = 0;
00903     cout << " show_base manipulator for scientific format   error\n"
00904          << "valid:  " << validstr << endl
00905          << "actual: " << outstr   << endl;
00906   }
00907 
00908   if(verbosity == VERBOSE){
00909     if(passed) {
00910       cout << " show_base manipulator      ok\n";
00911     } else {
00912       cout << " *** error(s) with show_base manipulator.\n";
00913     }
00914   }
00915   passed = 1;
00916 
00917 
00918 //======= Add Plus Manipulator ===========================================
00919   if(verbosity == REALLY_VERBOSE) {
00920   cout << "---- add plus ----------------------------------\n";
00921   }
00922 
00923 //------- plus sign manipulator for fixed format ------------------------------
00924   fmFixed.plus();
00925 
00926   if(verbosity == REALLY_VERBOSE) {
00927   cout << "     Fixed Format: " 
00928        << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00929        << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00930   }
00931   
00932   strstrm << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
00933           << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
00934   strstrm.getline(strbuf, STRBUF_LEN);
00935 
00936   outstr = strbuf;
00937   validstr = "< +8.0000> <+1234.0000> < +0.1235> <+123456789.0000>";
00938 
00939   if(outstr == validstr){
00940     if( verbosity >= REALLY_VERBOSE )
00941     cout << " plus manipulator for fixed format             ok\n";
00942   }
00943   else{
00944     passed = 0;
00945     cout << " plus manipulator for fixed format             error\n"
00946          << "valid:  " << validstr << endl
00947          << "actual: " << outstr   << endl;
00948   }
00949 
00950 //------- plus sign manipulator for general format ------------------------------
00951   fmGeneral.plus();
00952 
00953   if(verbosity == REALLY_VERBOSE) {
00954   cout << "   General Format: " 
00955        << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00956        << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00957   }
00958   
00959   strstrm << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
00960           << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
00961   strstrm.getline(strbuf, STRBUF_LEN);
00962 
00963   outstr = strbuf;
00964   validstr = "<      +8> <   +1234> < +0.1235> <+1.235e+08>";
00965 
00966   if(outstr == validstr){
00967     if( verbosity >= REALLY_VERBOSE )
00968     cout << " plus manipulator for general format           ok\n";
00969   }
00970   else{
00971     passed = 0;
00972     cout << " plus manipulator for general format           error\n"
00973          << "valid:  " << validstr << endl
00974          << "actual: " << outstr   << endl;
00975   }
00976 
00977 //------- plus sign manipulator for hex format ------------------------------
00978   fmHex.plus();
00979 
00980   if(verbosity == REALLY_VERBOSE) {
00981   cout << "       Hex Format: " 
00982        << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00983   }
00984   
00985   strstrm << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
00986   strstrm.getline(strbuf, STRBUF_LEN);
00987 
00988   outstr = strbuf;
00989   validstr = "<     0x8> <   0x4d2>";
00990 
00991   if(outstr == validstr){
00992     if( verbosity >= REALLY_VERBOSE )
00993     cout << " plus manipulator for hex format               ok\n";
00994   }
00995   else{
00996     passed = 0;
00997     cout << " plus manipulator for hex format               error\n"
00998          << "valid:  " << validstr << endl
00999          << "actual: " << outstr   << endl;
01000   }
01001 
01002 //------- plus sign manipulator for octal format ------------------------------
01003   fmOct.plus();
01004 
01005   if(verbosity == REALLY_VERBOSE) {
01006   cout << "     Octal Format: " 
01007        << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
01008   }
01009   
01010   strstrm << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
01011   strstrm.getline(strbuf, STRBUF_LEN);
01012 
01013   outstr = strbuf;
01014   validstr = "<     010> <   02322>";
01015 
01016   if(outstr == validstr){
01017     if( verbosity >= REALLY_VERBOSE )
01018     cout << " plus manipulator for octal format             ok\n";
01019   }
01020   else{
01021     passed = 0;
01022     cout << " plus manipulator for octal format             error\n"
01023          << "valid:  " << validstr << endl
01024          << "actual: " << outstr   << endl;
01025   }
01026 
01027 //------- plus sign manipulator for octal format ------------------------------
01028   fmScientific.plus();
01029 
01030   if(verbosity == REALLY_VERBOSE) {
01031   cout << "Scientific Format: " 
01032        << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
01033        << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
01034   }
01035   
01036   strstrm << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
01037           << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
01038   strstrm.getline(strbuf, STRBUF_LEN);
01039 
01040   outstr = strbuf;
01041   validstr = "<+8.0000e+00> <+1.2340e+03> <+1.2346e-01> <+1.2346e+08>";
01042 
01043   if(outstr == validstr){
01044     if( verbosity >= REALLY_VERBOSE )
01045     cout << " plus manipulator for octal format             ok\n";
01046   }
01047   else{
01048     passed = 0;
01049     cout << " plus manipulator for octal format             error\n"
01050          << "valid:  " << validstr << endl
01051          << "actual: " << outstr   << endl;
01052   }
01053 
01054   if(verbosity == VERBOSE){
01055     if(passed) {
01056       cout << " plus sign manipulator      ok\n";
01057     } else {
01058       cout << " *** error(s) with plus manipulator.\n";
01059     }
01060   }
01061   passed = 1;
01062 
01063 
01064 //======= Trailing Zeros Manipulator ===========================================
01065   if(verbosity == REALLY_VERBOSE) {
01066   cout << "---- trailing zeros ----------------------------------\n";
01067   }
01068 
01069 //------- trailing zeros manipulator for fixed format ------------------------------
01070   fmFixed.trailing_zeros();
01071 
01072   if(verbosity == REALLY_VERBOSE) {
01073   cout << "     Fixed Format: " 
01074        << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
01075        << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
01076   }
01077   
01078   strstrm << "<" << fmFixed(i1) << "> <" << fmFixed(i2) << "> " 
01079           << "<" << fmFixed(d1) << "> <" << fmFixed(d2) << ">\n";
01080   strstrm.getline(strbuf, STRBUF_LEN);
01081 
01082   outstr = strbuf;
01083   validstr = "< +8.0000> <+1234.0000> < +0.1235> <+123456789.0000>";
01084 
01085   if(outstr == validstr){
01086     if( verbosity >= REALLY_VERBOSE )
01087     cout << " trailing zeros manipulator for fixed format   ok\n";
01088   }
01089   else{
01090     passed = 0;
01091     cout << " trailing zeros manipulator for fixed format   error\n"
01092          << "valid:  " << validstr << endl
01093          << "actual: " << outstr   << endl;
01094   }
01095 
01096 //------- trailing zeros manipulator for general format ------------------------------
01097   fmGeneral.trailing_zeros();
01098 
01099   if(verbosity == REALLY_VERBOSE) {
01100   cout << "   General Format: " 
01101        << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
01102        << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
01103   }
01104   
01105   strstrm << "<" << fmGeneral(i1) << "> <" << fmGeneral(i2) << "> " 
01106           << "<" << fmGeneral(d1) << "> <" << fmGeneral(d2) << ">\n";
01107   strstrm.getline(strbuf, STRBUF_LEN);
01108 
01109   outstr = strbuf;
01110   validstr = "<  +8.000> <  +1234.> < +0.1235> <+1.235e+08>";
01111 
01112   if(outstr == validstr){
01113     if( verbosity >= REALLY_VERBOSE )
01114     cout << " trailing zeros manipulator for general format ok\n";
01115   }
01116   else{
01117     passed = 0;
01118     cout << " trailing zeros manipulator for general format error\n"
01119          << "valid:  " << validstr << endl
01120          << "actual: " << outstr   << endl;
01121   }
01122 
01123 //------- trailing zeros manipulator for hex format ------------------------------
01124   fmHex.trailing_zeros();
01125 
01126   if(verbosity == REALLY_VERBOSE) {
01127   cout << "       Hex Format: " 
01128        << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
01129   }
01130   
01131   strstrm << "<" << fmHex(i1) << "> <" << fmHex(i2) << ">\n";
01132   strstrm.getline(strbuf, STRBUF_LEN);
01133 
01134   outstr = strbuf;
01135   validstr = "<     0x8> <   0x4d2>";
01136 
01137   if(outstr == validstr){
01138     if( verbosity >= REALLY_VERBOSE )
01139     cout << " trailing zeros manipulator for hex format     ok\n";
01140   }
01141   else{
01142     passed = 0;
01143     cout << " trailing zeros manipulator for hex format     error\n"
01144          << "valid:  " << validstr << endl
01145          << "actual: " << outstr   << endl;
01146   }
01147 
01148 //------- trailing zeros manipulator for octal format ------------------------------
01149   fmOct.trailing_zeros();
01150 
01151   if(verbosity == REALLY_VERBOSE) {
01152   cout << "     Octal Format: " 
01153        << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
01154   }
01155   
01156   strstrm << "<" << fmOct(i1) << "> <" << fmOct(i2) << ">\n";
01157   strstrm.getline(strbuf, STRBUF_LEN);
01158 
01159   outstr = strbuf;
01160   validstr = "<     010> <   02322>";
01161 
01162   if(outstr == validstr){
01163     if( verbosity >= REALLY_VERBOSE )
01164     cout << " trailing zeros manipulator for octal format   ok\n";
01165   }
01166   else{
01167     passed = 0;
01168     cout << " trailing zeros manipulator for octal format   error\n"
01169          << "valid:  " << validstr << endl
01170          << "actual: " << outstr   << endl;
01171   }
01172 
01173 //------- trailing zeros manipulator for octal format ------------------------------
01174   fmScientific.trailing_zeros();
01175 
01176   if(verbosity == REALLY_VERBOSE) {
01177   cout << "Scientific Format: " 
01178        << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
01179        << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
01180   }
01181   
01182   strstrm << "<" << fmScientific(i1) << "> <" << fmScientific(i2) << "> "
01183           << "<" << fmScientific(d1) << "> <" << fmScientific(d2) << ">\n";
01184   strstrm.getline(strbuf, STRBUF_LEN);
01185 
01186   outstr = strbuf;
01187   validstr = "<+8.0000e+00> <+1.2340e+03> <+1.2346e-01> <+1.2346e+08>";
01188 
01189   if(outstr == validstr){
01190     if( verbosity >= REALLY_VERBOSE )
01191     cout << " trailing zeros manipulator for sci. format    ok\n";
01192   }
01193   else{
01194     passed = 0;
01195     cout << " trailing zeros manipulator for sci. format    error\n"
01196          << "valid:  " << validstr << endl
01197          << "actual: " << outstr   << endl;
01198   }
01199 
01200   if(verbosity == VERBOSE){
01201     if(passed) {
01202       cout << " trailing zeros manipulator ok\n";
01203     } else {
01204       cout << " *** error(s) with trailing zeros manipulator.\n";
01205     }
01206   }
01207   passed = 1;
01208 
01209   if(verbosity == QUIET){
01210     cout << " Manipulators ok\n";
01211   }
01212 
01213   return passed;
01214 }

bool MsgFormatValidate::TestMsgBoundFormat (  )  [private]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1