Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
test-target-obj.hpp
Go to the documentation of this file.
1/*
2 TEST-TARGET-OBJ.hpp - a test (stub) target object for testing the factories
3
4 Copyright (C)
5 2008, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
21#ifndef LIBRARY_TEST_TARGET_OBJ_H
22#define LIBRARY_TEST_TARGET_OBJ_H
23
24
25#include "lib/test/run.hpp"
26#include "lib/format-string.hpp"
27#include "lib/format-cout.hpp"
28
29#include <boost/lexical_cast.hpp>
30#include <string>
31
32
33namespace lib {
34namespace test{
35
36 using util::_Fmt;
37 using boost::lexical_cast;
38 using std::string;
39
46 {
48 string* heapData_;
49 string* heapArray_;
50
51 public:
53 virtual ~TestTargetObj();
54
55 virtual operator string () const;
56 };
57
58
59
60 inline
62 : cnt_ (num)
63 , heapData_ (new string(num,'*'))
64 , heapArray_ (new string[num])
65 {
66 for (uint i=0; i<cnt_; ++i)
67 heapArray_[i] = lexical_cast<string>(i);
68 cout << _Fmt("ctor TargetObj(%i) successful\n") % cnt_;
69 }
70
71
72 inline
74 {
75 delete heapData_;
76 delete[] heapArray_;
77 cout << _Fmt("dtor ~TargetObj(%i) successful\n") % cnt_;
78 }
79
80
81
82 inline
83 TestTargetObj::operator string () const
84 {
85 string array_contents = "{";
86 for (uint i=0; i<cnt_; ++i)
87 array_contents += heapArray_[i]+",";
88 array_contents+="}";
89
90 return _Fmt(".....TargetObj(%1%): data=\"%2%\", array[%1%]=%3%")
91 % cnt_ % *heapData_ % array_contents;
92 }
93
94
95
96
97}} // namespace lib::test
98#endif
Target object to be created by Test-Factories or as Singleton.
A front-end for using printf-style formatting.
Automatically use custom string conversion in C++ stream output.
Front-end for printf-style string template interpolation.
unsigned int uint
Definition integral.hpp:29
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
Simplistic test class runner.