My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include "TypeTraits.h"
#include "Assert.h"

namespace MockItNow
{
template<typename T>
struct Storage
{
Storage(const T& value_)
: value(value_),
address(&value_)
{
MOCKITNOW_STATIC_ASSERT(IsReference<T>::Value == false, ArgumentTypeIsAReference);
MOCKITNOW_STATIC_ASSERT(IsConst<T>::Value == false, ArgumentTypeIsConst);
}

Storage(const T* address_)
: value(*address_),
address(address_)
{
MOCKITNOW_STATIC_ASSERT(IsReference<T>::Value == false, ArgumentTypeIsAReference);
MOCKITNOW_STATIC_ASSERT(IsConst<T>::Value == false, ArgumentTypeIsConst);
}

T value;
const T* address;

private:

Storage(const Storage&);
Storage& operator=(const Storage&);
};

template<>
struct Storage<char *>
{
Storage(const char* value_)
{
value = new char[strlen(value_) + 1];
strcpy(value, value_);
}

~Storage()
{
delete[] value;
}

char* value;

private:

Storage(const Storage&);
Storage& operator=(const Storage&);
};
}
Show details Hide details

Change log

r9 by rorydriscoll on Mar 13, 2009   Diff
- Latest version of MockItNow with ability
to do out pointer arguments.
Go to: 
Project members, sign in to write a code review

Older revisions

r7 by rorydriscoll on Jan 15, 2009   Diff
- Added support for recording
functions and throwing exceptions
r6 by rorydriscoll on Nov 15, 2008   Diff
Added macro to define a storage type
for a class
r2 by RoryDriscoll on May 17, 2008   Diff
First drop
All revisions of this file

File info

Size: 1060 bytes, 57 lines
Hosted by Google Code