summaryrefslogtreecommitdiff
path: root/src/tests/sharedcore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/sharedcore.cpp')
-rw-r--r--src/tests/sharedcore.cpp98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/tests/sharedcore.cpp b/src/tests/sharedcore.cpp
deleted file mode 100644
index c68f07b..0000000
--- a/src/tests/sharedcore.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/sharedcore.h"
9#include "bu/sio.h"
10
11using namespace Bu;
12
13struct ShintCore
14{
15 int val;
16};
17class Shint : public Bu::SharedCore<Shint, struct ShintCore>
18{
19public:
20 Shint()
21 {
22 core->val = 0;
23 }
24
25 Shint( int val )
26 {
27 core->val = val;
28 }
29
30 int getVal() const
31 {
32 return core->val;
33 }
34
35 void setValBad( int val )
36 {
37 core->val = val;
38 }
39
40 void setVal( int val )
41 {
42 _hardCopy();
43 core->val = val;
44 }
45
46 bool operator==( const Shint &rhs )
47 {
48 if( core == rhs.core )
49 {
50 sio << "Same pointer (" << Fmt::ptr() << core << ")" << sio.nl;
51 return true;
52 }
53 if( core->val == rhs.core->val )
54 {
55 sio << "Same value " << core->val << " ("
56 << Fmt::ptr() << core << " vs "
57 << Fmt::ptr() << rhs.core << ")"
58 << sio.nl;
59 return true;
60 }
61 sio << "Different" << sio.nl;
62 return false;
63 }
64};
65
66#define line( x ) sio << __FILE__ ": " << __LINE__ << ": " << #x << sio.nl; x
67
68int main()
69{
70 line( Shint a; )
71 line( Shint b( 5 ); )
72
73 line( a == b; )
74
75 line( b = a; )
76 line( a == b; )
77
78 line( b.setValBad( 12 ); )
79 sio << a.getVal() << " != " << b.getVal() << sio.nl;
80 line( a == b; )
81
82 line( a.setVal( 3 ); )
83 sio << a.getVal() << " != " << b.getVal() << sio.nl;
84 line( a == b; )
85
86 line( a.setVal( b.getVal() ); )
87 line( a == b; )
88
89 {
90 Shint c( b );
91 Shint d( c );
92 sio << c.getVal();
93 d.setVal( 43 );
94 }
95
96 sio << b.getVal();
97}
98