xref: /haiku/src/tests/kits/app/bmessage/MessageBPointItemTest.h (revision bef39d09af0c445880b7dd9cc039d39a89d66365)
1 //------------------------------------------------------------------------------
2 //	MessageBPointItemTest.h
3 //
4 //------------------------------------------------------------------------------
5 
6 #ifndef MESSAGEBPOINTITEMTEST_H
7 #define MESSAGEBPOINTITEMTEST_H
8 
9 // Standard Includes -----------------------------------------------------------
10 
11 // System Includes -------------------------------------------------------------
12 
13 // Project Includes ------------------------------------------------------------
14 
15 // Local Includes --------------------------------------------------------------
16 #include "MessageItemTest.h"
17 
18 // Local Defines ---------------------------------------------------------------
19 
20 // Globals ---------------------------------------------------------------------
21 
22 typedef TMessageItemFuncPolicy
23 <
24 	BPoint,
25 	&BMessage::AddPoint,
26 	&BMessage::FindPoint,
27 	&BMessage::FindPoint,
28 	&BMessage::FindPoint,
29 	&BMessage::HasPoint,
30 	&BMessage::ReplacePoint
31 >
32 TPointFuncPolicy;
33 
34 struct TPointInitPolicy : public ArrayTypeBase<BPoint>
35 {
ZeroTPointInitPolicy36 	inline static BPoint Zero()		{ return BPoint(0.0, 0.0); }
Test1TPointInitPolicy37 	inline static BPoint Test1()	{ return BPoint(10.0, 10.0); }
Test2TPointInitPolicy38 	inline static BPoint Test2()	{ return BPoint(20.0, 20.0); }
SizeOfTPointInitPolicy39 	inline static size_t SizeOf(const BPoint&)	{ return sizeof (BPoint); }
ArrayTPointInitPolicy40 	inline static ArrayType Array()
41 	{
42 		ArrayType array;
43 		array.push_back(BPoint(30.0, 30.0));
44 		array.push_back(BPoint(40.0, 40.0));
45 		array.push_back(BPoint(50.0, 50.0));
46 		return array;
47 	}
48 };
49 
50 struct TPointAssertPolicy
51 {
ZeroTPointAssertPolicy52 	inline static BPoint Zero()		{ return BPoint(0.0, 0.0); }
InvalidTPointAssertPolicy53 	inline static BPoint Invalid()	{ return BPoint(0.0, 0.0); }
SizeTPointAssertPolicy54 	inline static bool   Size(size_t size, BPoint& p)
55 		{ return size == sizeof (p); }
56 };
57 
58 typedef TMessageItemTest
59 <
60 	BPoint,
61 	B_POINT_TYPE,
62 	TPointFuncPolicy,
63 	TPointInitPolicy,
64 	TPointAssertPolicy
65 >
66 TMessageBPointItemTest;
67 
68 std::ostream& operator<<(std::ostream& os, const BPoint& point)
69 {
70 	int precision = os.precision();
71 	os << "point(x:" << point.x << ", y:" << point.y;
72 	os.precision(precision);
73 	return os;
74 }
75 
76 #endif	// MESSAGEBPOINTITEMTEST_H
77 
78 /*
79  * $Log $
80  *
81  * $Id  $
82  *
83  */
84 
85