MsgStreamValidate Class Reference

#include <MsgStreamValidate.h>

List of all members.

Public Member Functions

 MsgStreamValidate ()
 ~MsgStreamValidate ()
bool RunAllTests ()

Private Member Functions

bool TestMsgStreamConstructors ()
bool TestMsgStreamManipulators ()
bool TestMsgStreamStreamers ()

Detailed Description

Definition at line 10 of file MsgStreamValidate.h.


Constructor & Destructor Documentation

MsgStreamValidate::MsgStreamValidate (  ) 

Definition at line 18 of file MsgStreamValidate.cxx.

00018 {}

MsgStreamValidate::~MsgStreamValidate (  ) 

Definition at line 22 of file MsgStreamValidate.cxx.

00022 {}


Member Function Documentation

bool MsgStreamValidate::RunAllTests ( void   ) 

Definition at line 173 of file MsgStreamValidate.cxx.

References TestMsgStreamConstructors(), TestMsgStreamManipulators(), and TestMsgStreamStreamers().

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

00174 {
00175   bool passed = true;
00176   
00177   passed &= this->TestMsgStreamConstructors();
00178   passed &= this->TestMsgStreamManipulators();
00179   passed &= this->TestMsgStreamStreamers();
00180   
00181   return passed;
00182 }

bool MsgStreamValidate::TestMsgStreamConstructors (  )  [private]

Definition at line 26 of file MsgStreamValidate.cxx.

Referenced by RunAllTests().

00027 {
00028   bool passed = true;
00029   MsgStream defaultStream;
00030   MsgStream namedStream1("NS1");
00031   MsgStream namedStream2("NS2");
00032   
00033   cout << "===== testMsgStreamConstructors\n";
00034   /*
00035   // GCC 4.5.0 warns that address of these will never be NULL 
00036   if (&defaultStream == 0 ||
00037       &namedStream1  == 0 ||
00038       &namedStream2  == 0) {
00039     cout << "Constructors Failed\n";
00040     return false;
00041   }
00042   */
00043   
00044   cout << defaultStream;
00045   cout << namedStream1;
00046   cout << namedStream2;
00047 
00048   return passed;
00049 }

bool MsgStreamValidate::TestMsgStreamManipulators (  )  [private]

Definition at line 53 of file MsgStreamValidate.cxx.

References Msg::kCVSId, Msg::kFile, Msg::kLine, Msg::kMinLogLevel, Msg::kName, Msg::kNLogLevel, Msg::kPriority, Msg::kTime, Msg::kVerbose, s(), and MsgStream::SetLogLevel().

Referenced by RunAllTests().

00054 {
00055   bool passed = true;
00056   int i;
00057   MsgStream s("MS1");
00058   Msg::LogLevel_t lvl;
00059   
00060   cout << "===== testMsgStreamManipulators\n";
00061   cout << "Default Stream:\n";
00062   cout << s;
00063 
00064   cout << "SetLogLevel:\n";
00065   s.SetLogLevel(Msg::kVerbose);
00066   cout << s;
00067 
00068   cout << "SetFormat:\n";
00069   for (i=Msg::kMinLogLevel; i<Msg::kNLogLevel; ++i) {
00070     lvl = (Msg::LogLevel_t)i;
00071     s.SetFormat(lvl, Msg::kPriority + Msg::kTime + Msg::kCVSId);
00072   }
00073   cout << s;
00074 
00075   cout << "AddFormat:\n";
00076   for (i=Msg::kMinLogLevel; i<Msg::kNLogLevel; ++i) {
00077     lvl = (Msg::LogLevel_t)i;
00078     s.AddFormat(lvl, Msg::kName + Msg::kFile + Msg::kLine);
00079   }
00080   cout << s;
00081 
00082   cout << "RemoveFormat:\n";
00083   for (i=Msg::kMinLogLevel; i<Msg::kNLogLevel; ++i) {
00084     lvl = (Msg::LogLevel_t)i;
00085     s.RemoveFormat(lvl, 
00086                    Msg::kPriority + Msg::kName + Msg::kTime + 
00087                    Msg::kFile + Msg::kCVSId + Msg::kLine);
00088   }
00089   cout << s;
00090 
00091   cout << "AttachOStream:\n";
00092   for (i=Msg::kMinLogLevel; i<Msg::kNLogLevel; ++i) {
00093     lvl = (Msg::LogLevel_t)i;
00094     s.AttachOStream(lvl, "cout");
00095     s.AttachOStream(lvl, "cerr");
00096     s.AttachOStream(lvl, "afile.txt");
00097   }
00098   cout << s;
00099 
00100   cout << "DetachOStream:\n";
00101   for (i=Msg::kMinLogLevel; i<Msg::kNLogLevel; ++i) {
00102     lvl = (Msg::LogLevel_t)i;
00103     s.DetachOStream(lvl, "cout");
00104     s.AttachOStream(lvl, "cerr");
00105     s.DetachOStream(lvl, "afile.txt");
00106   }
00107   cout << s;
00108 
00109   return passed;
00110 }

bool MsgStreamValidate::TestMsgStreamStreamers (  )  [private]

Definition at line 114 of file MsgStreamValidate.cxx.

References __CVSID__, MsgStream::AttachOStream(), MsgStream::Close(), Msg::kCVSId, Msg::kFile, Msg::kHost, Msg::kInfo, Msg::kLine, Msg::kName, Msg::kPID, Msg::kPriority, Msg::kTime, Msg::kVerbose, s(), and MsgStream::SetFormat().

Referenced by RunAllTests().

00115 {
00116   bool passed = true;
00117   MsgStream s("Msg");
00118   string str = "String type works!";
00119   
00120   s.AttachOStream(Msg::kInfo, "cout");
00121   s.AttachOStream(Msg::kInfo, "msgFile1.txt");
00122   s.AttachOStream(Msg::kInfo, "msgFile2.txt");
00123   
00124   s.SetFormat(Msg::kInfo,
00125               Msg::kPriority +
00126               Msg::kName     +
00127               Msg::kTime     +
00128               Msg::kFile     +
00129               Msg::kCVSId    +
00130               Msg::kLine     +
00131               Msg::kHost     +
00132               Msg::kPID);
00133   
00134   s(Msg::kInfo,
00135     __FILE__,
00136     __CVSID__,
00137     __LINE__)
00138       << "\n This message should get sent to: \n" 
00139       << " cout, msgFile1.txt, msgFile2.txt\n"
00140       << " (" << 1 << " " << 1.2 << " " << 1.0e21 << ")\n";
00141   
00142   s(Msg::kVerbose,
00143     __FILE__,
00144     __CVSID__,
00145     __LINE__)
00146       << "!!! Its an error if this message get printed!!!\n";
00147   
00148   s(Msg::kInfo,
00149     __FILE__,
00150     __CVSID__,
00151     __LINE__)
00152       << "This checks the use of endl" << endl;
00153   
00154   s(Msg::kInfo,
00155     __FILE__,
00156     __CVSID__,
00157     __LINE__)
00158       << "This checks the use of setw" << setw(9) << "1.23\n";
00159   
00160   s(Msg::kInfo,
00161     __FILE__,
00162     __CVSID__,
00163     __LINE__)
00164       << "This checks the streamer for strings:" << str << endl;
00165   
00166   s.Close();
00167   
00168   return passed;
00169 }


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1