t_utility.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : test_utility                                                      *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *******************************************************************************
00007 * Copyright (c) 1999-$now By Author.  This program is free software; you can  *
00008 * redistribute it and/or modify it under the terms of the GNU General Public  *
00009 * License as published by the Free Software Foundation; either version 2 of   *
00010 * the License or (at your option) any later version.  This is online at:      *
00011 *     http://www.fsf.org/copyleft/gpl.html                                    *
00012 * Please send any updates to: fred@gruntose.com                               *
00013 \*****************************************************************************/
00014 
00015 #include <basis/function.h>
00016 #include <basis/guards.h>
00017 #include <basis/istring.h>
00018 #include <basis/mutex.h>
00019 #include <basis/portable.h>
00020 #include <data_struct/static_memory_gremlin.h>
00021 #include <opsystem/application_shell.h>
00022 #include <loggers/console_logger.h>
00023 #include <loggers/file_logger.h>
00024 #include <data_struct/static_memory_gremlin.h>
00025 
00026 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger(), s)
00027 
00028 static bool hit_by_derived = false;
00029 static bool hit_by_base = false;
00030 
00031 class base_bogus
00032 {
00033 public:
00034   application_shell &_parent;
00035 
00036   base_bogus(application_shell &parent) : _parent(parent) {}
00037   virtual ~base_bogus() { hit_by_base = true; }
00038 };
00039 
00041 
00042 class derived_bogus : public base_bogus
00043 {
00044 public:
00045   derived_bogus(application_shell &parent) : base_bogus(parent) {}
00046   virtual ~derived_bogus() { hit_by_derived = true; }
00047 };
00048 
00050 
00051 const istring &dorf() { STATIC_STRING("BUBOIBOBOBOBOB"); }
00052 
00053 void arf(const istring &to_try)
00054 {
00055   istring urf = to_try + ";;;;;";
00056 }
00057 
00058 SAFE_STATIC(istring_object, hyurlo, ("beepbeep"))
00059 
00060 const istring budro("ubbu");
00061 
00062 void test_statics()
00063 {
00064   istring ted = hyurlo();
00065   ted += dorf();
00066   ted += budro;
00067   arf(ted);
00068   arf(dorf());
00069   arf(hyurlo());
00070   arf(budro);
00071   arf("oiuweoiweoiwe");
00072 }
00073 
00075 
00076 class test_utility : public application_shell
00077 {
00078 public:
00079   test_utility() : application_shell(class_name()) {}
00080 
00081   IMPLEMENT_CLASS_NAME("test_utility");
00082 
00083   int execute();
00084 
00085 private:
00086 };
00087 
00088 int test_utility::execute()
00089 {
00090   FUNCDEF("execute");
00091   LOG(istring("starting ") + timestamp(true, true) + "<- with space");
00092   LOG(istring("starting ") + timestamp(false, false) + "<- no space or date");
00093 
00094   test_statics();
00095 
00096   derived_bogus *to_whack = new derived_bogus(*this);
00097   WHACK(to_whack);
00098   if (!hit_by_base)
00099     deadly_error("test_utility", "execute", "base destructor was not hit!");
00100   if (!hit_by_derived)
00101     deadly_error("test_utility", "execute", "derived destructor was not hit!");
00102 
00103   test_statics();
00104 
00105   LOG(istring("ending ") + timestamp(false, true) + "<- no space");
00106   LOG(istring("ending ") + timestamp(true, false) + "<- no date");
00107 
00108   LOG("this should be a 100 ms sleep...");
00109   portable::sleep_ms(100);
00110   LOG("100 ms sleep done now.");
00111 
00112   LOG("this should be a 340 ms sleep...");
00113   portable::sleep_ms(340);
00114   LOG("340 ms sleep done now.");
00115 
00116   guards::alert_message("utility:: works for those functions tested.");
00117   return 0;
00118 }
00119 
00121 
00122 HOOPLE_MAIN(test_utility, )
00123 

Generated on Fri Nov 21 04:30:06 2008 for HOOPLE Libraries by  doxygen 1.5.1