feisty meow concerns codebase 2.140
test_safe_callback.cpp
Go to the documentation of this file.
1/*****************************************************************************\
2* *
3* Name : test_safe_callback *
4* Author : Chris Koeritz *
5* *
6* Purpose: *
7* *
8* Tests the safe callback object slightly. Mainly this is to ensure that *
9* no memory leaks are being caused by the object and that minimal support is *
10* provided by the object. *
11* *
12*******************************************************************************
13* Copyright (c) 1998-$now By Author. This program is free software; you can *
14* redistribute it and/or modify it under the terms of the GNU General Public *
15* License as published by the Free Software Foundation; either version 2 of *
16* the License or (at your option) any later version. This is online at: *
17* http://www.fsf.org/copyleft/gpl.html *
18* Please send any updates to: fred@gruntose.com *
19\*****************************************************************************/
20
22#include <basis/astring.h>
23#include <basis/guards.h>
27//#include <loggers/file_logger.h>
30#include <unit_test/unit_base.h>
31
32using namespace application;
33using namespace basis;
34using namespace configuration;
35//using namespace mathematics;
36//using namespace filesystem;
37using namespace loggers;
38using namespace processes;
39//using namespace structures;
40//using namespace textual;
41using namespace timely;
42using namespace unit_test;
43
44#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
45
47
49 ("t_safe_callback.log");
50 // where our debugging output goes by default.
51
53 // our macro for logging with a timestamp.
54
55//hmmm: this tester doesn't really do very much at all.
56// how about a more aggressive test, which has a bunch of threads using
57// safe callback?
58
59class cb_tester : public safe_callback
60{
61public:
62 cb_tester() : safe_callback() {}
63 ~cb_tester() { end_availability(); }
64
65 virtual void real_callback(callback_data_block &)
66 { /* do nothing. */ }
67};
68
69//hmmm: move this to using a class based approach, based on unit_test and application_shell.
70
71int main(int formal(argc), char *formal(argv)[])
72{
74
75 cb_tester testing;
76
77 critical_events::alert_message("safe_callback:: works for all functions tested.");
78 return 0;
79}
80
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
static basis::astring make_logfile_name(const basis::astring &base_name)
generates an installation appropriate log file name from "base_name".
static void alert_message(const char *info, const char *title="Alert Message")
shows the message in "info", with an optional "title" on the message.
a simple place-holder that anonymizes the type passed to the callback.
A reasonably easy way to make callbacks safe from shutdown ordering issues.
virtual void real_callback(callback_data_block &new_data)=0
derived classes implement this to provide their callback functionality.
void end_availability()
prepares to shut down this object.
#define formal(parameter)
This macro just eats what it's passed; it marks unused formal parameters.
Definition definitions.h:48
Provides macros that implement the 'main' program of an application.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
Definition array.h:30
A logger that sends to the console screen using the standard output device.
#include <time.h>
Useful support functions for unit testing, especially within hoople.
Definition unit_base.cpp:35
const astring LOGFILE_NAME
int main(int formal(argc), char *formal(argv)[])