"README.md" did not exist on "67e82750f3cdc46f1cd25b3679b0efdaf0b41857"
Newer
Older
#include "nullObject.H"
#include "IOstreams.H"
using namespace Foam;
class SimpleClass
{
public:
//- Null constructor
SimpleClass()
{}
};
int main()
{
// Test pointer and reference to a class
SimpleClass* ptrToClass = new SimpleClass;
SimpleClass& refToClass(*ptrToClass);
typedef unsigned long ptrval;
Info<<"nullObject address=" << ptrval(&(nullObjectPtr)) << endl;
Info<<"sizeof(nullObject)" << " == "
<< sizeof(NullObject::nullObject)
<< " vs. sizeof(void*)" << " == " << sizeof(void*)
<< endl;
Info<<"nullObject pointer:" << ptrval(nullObjectPtr->pointer()) << endl;
Info<<"nullObject value:" << nullObjectPtr->value() << endl;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
if (notNull(ptrToClass))
{
Info<< "Pass: ptrToClass is not null" << endl;
}
else
{
Info<< "FAIL: refToClass is null" << endl;
}
if (notNull(refToClass))
{
Info<< "Pass: refToClass is not null" << endl;
}
else
{
Info<< "FAIL: refToClass is null" << endl;
}
// Test pointer and reference to the nullObject
const SimpleClass* ptrToNull(NullObjectPtr<SimpleClass>());
const SimpleClass& refToNull(*ptrToNull);
if (isNull(ptrToNull))
{
Info<< "Pass: ptrToNull is null" << endl;
}
else
{
Info<< "FAIL: ptrToNull is not null" << endl;
}
if (isNull(refToNull))
{
Info<< "Pass: refToNull is null" << endl;
}
else
{
Info<< "FAIL: refToNull is not null" << endl;
}
// Clean-up
delete ptrToClass;
return 0;
}