Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

test-system.cc

00001 /*
00002 *  Name:      test_system.cc
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   Test for operating system
00005 *  Date:      $Date: 2003/04/14 00:18:36 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 1994-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #include <iostream>
00027 #include <mpcl/system/system.hh>
00028 #include <mpcl/test.h>
00029 #include <mpcl/text/string.hh>
00030 #include <mpcl/util/logging/log.hh>
00031 #include <vector>
00032 
00033 
00035 int main (void)
00036 {
00037 
00038   using mpcl::system::TSystem;
00039   using mpcl::system::tSystem;
00040   using mpcl::text::TString;
00041   using mpcl::util::logging::alert;
00042   using mpcl::util::logging::authpriv;
00043   using mpcl::util::logging::crit;
00044   using mpcl::util::logging::cron;
00045   using mpcl::util::logging::daemon;
00046   using mpcl::util::logging::debug;
00047   using mpcl::util::logging::emerg;
00048   using mpcl::util::logging::err;
00049   using mpcl::util::logging::header;
00050   using mpcl::util::logging::info;
00051   using mpcl::util::logging::kern;
00052   using mpcl::util::logging::local0;
00053   using mpcl::util::logging::local1;
00054   using mpcl::util::logging::local2;
00055   using mpcl::util::logging::local3;
00056   using mpcl::util::logging::local4;
00057   using mpcl::util::logging::local5;
00058   using mpcl::util::logging::local6;
00059   using mpcl::util::logging::local7;
00060   using mpcl::util::logging::lpr;
00061   using mpcl::util::logging::mail;
00062   using mpcl::util::logging::news;
00063   using mpcl::util::logging::notice;
00064   using mpcl::util::logging::tLog;
00065   using mpcl::util::logging::user;
00066   using mpcl::util::logging::uucp;
00067   using mpcl::util::logging::warning;
00068   using std::endl;
00069   using std::vector;
00070 
00071   TEST_INIT ("tests for class 'TSystem'");
00072 
00073   TString                        yPathCollection1 = ":/second/third:last";
00074   TString                        yPathCollection2 = ":::::last path";
00075   TString                        yPathCollection3 = ":0:1:2:3:4:";
00076   TString                        yPathCollection4 = ":0/:1:2/:3:4/:";
00077   TSystem::TBigEndianBuffer      tBuffer1 ((const unsigned char*) "\01\02\03\04", 4);
00078   TSystem::TLittleEndianBuffer   tBuffer2 ((const unsigned char*) "\04\03\02\01", 4);
00079   vector<TString>                tPathVector1 (tSystem.getPathItems (yPathCollection1));
00080   vector<TString>                tPathVector2 (tSystem.getPathItems (yPathCollection2));
00081   vector<TString>                tPathVector3 (tSystem.getPathItems (yPathCollection3));
00082   vector<TString>                tPathVector4 (tSystem.getPathItems (yPathCollection4));
00083 
00084   TEST_NUMBERS (0x01020304, tBuffer1);
00085   TEST_NUMBERS (0x01020304, tBuffer2);
00086 
00087   TEST_STRINGS (tPathVector1 [0].c_str(), "/second/third/");
00088   TEST_STRINGS (tPathVector1 [1].c_str(), "last/");
00089   TEST_NUMBERS (tPathVector1.size(),      2);
00090   TEST_STRINGS (tPathVector2 [0].c_str(), "last path/");
00091   TEST_NUMBERS (tPathVector2.size(),      1);
00092   TEST_STRINGS (tPathVector3 [0].c_str(), "0/");
00093   TEST_STRINGS (tPathVector3 [1].c_str(), "1/");
00094   TEST_STRINGS (tPathVector3 [2].c_str(), "2/");
00095   TEST_STRINGS (tPathVector3 [3].c_str(), "3/");
00096   TEST_STRINGS (tPathVector3 [4].c_str(), "4/");
00097   TEST_NUMBERS (tPathVector3.size(),      5);
00098   TEST_STRINGS (tPathVector4 [0].c_str(), "0/");
00099   TEST_STRINGS (tPathVector4 [1].c_str(), "1/");
00100   TEST_STRINGS (tPathVector4 [2].c_str(), "2/");
00101   TEST_STRINGS (tPathVector4 [3].c_str(), "3/");
00102   TEST_STRINGS (tPathVector4 [4].c_str(), "4/");
00103   TEST_NUMBERS (tPathVector4.size(),      5);
00104   TEST_NUMBERS (true, ( tSystem.getFileSize (__FILE__) > __LINE__ ));
00105 
00106   //
00107   //  Writes log messages also on 'cerr'.
00108   //
00109   if ( !TEST_IN_SILENT_MODE )
00110   {
00111     tLog.also (std::cerr);
00112   }
00113   
00114   //
00115   //  Tests log level (must be checked by the user).
00116   //
00117   tLog <<            header << "testing class tLog using default log level"   << endl;
00118   tLog << emerg   << header << "testing class tLog using 'emerg' log level"   << endl;
00119   tLog << alert   << header << "testing class tLog using 'alert' log level"   << endl;
00120   tLog << crit    << header << "testing class tLog using 'crit' log level"    << endl;
00121   tLog << err     << header << "testing class tLog using 'err' log level"     << endl;
00122   tLog << warning << header << "testing class tLog using 'warning' log level" << endl;
00123   tLog << notice  << header << "testing class tLog using 'notice' log level"  << endl;
00124   tLog << info    << header << "testing class tLog using 'info' log level"    << endl;
00125   tLog << debug   << header << "testing class tLog using 'debug' log level"   << endl;
00126 
00127   //
00128   //  Tests log facilities (must be checked by the user).
00129   //
00130   tLog << authpriv << header << "testing class tLog using 'authpriv' log facility" << endl;
00131   tLog << cron     << header << "testing class tLog using 'cron'     log facility" << endl;
00132   tLog << daemon   << header << "testing class tLog using 'daemon'   log facility" << endl;
00133   tLog << kern     << header << "testing class tLog using 'kern'     log facility" << endl;
00134   tLog << local0   << header << "testing class tLog using 'local0'   log facility" << endl;
00135   tLog << local1   << header << "testing class tLog using 'local1'   log facility" << endl;
00136   tLog << local2   << header << "testing class tLog using 'local2'   log facility" << endl;
00137   tLog << local3   << header << "testing class tLog using 'local3'   log facility" << endl;
00138   tLog << local4   << header << "testing class tLog using 'local4'   log facility" << endl;
00139   tLog << local5   << header << "testing class tLog using 'local5'   log facility" << endl;
00140   tLog << local6   << header << "testing class tLog using 'local6'   log facility" << endl;
00141   tLog << local7   << header << "testing class tLog using 'local7'   log facility" << endl;
00142   tLog << lpr      << header << "testing class tLog using 'lpr'      log facility" << endl;
00143   tLog << mail     << header << "testing class tLog using 'mail'     log facility" << endl;
00144   tLog << news     << header << "testing class tLog using 'news'     log facility" << endl;
00145   tLog << user     << header << "testing class tLog using 'user'     log facility" << endl;
00146   tLog << uucp     << header << "testing class tLog using 'uucp'     log facility" << endl;
00147 
00148   //
00149   //  Tests for other methods (must be checked by the user).
00150   //
00151   tLog.debug ("testing method TLog::debug() method");
00152 
00153   TEST_MEMORY_STATUS;
00154   TEST_RETURN_CODE;
00155 
00156 }  // main()

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18