xref: /haiku/src/tests/kits/app/bmessage/MessageBRectItemTest.h (revision 3dfd9cb95ce45f59160d50975210bc55e3fc0709)
1 //------------------------------------------------------------------------------
2 //	MessageBRectItemTest.h
3 //
4 //------------------------------------------------------------------------------
5 
6 #ifndef MESSAGEBRECTITEMTEST_H
7 #define MESSAGEBRECTITEMTEST_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 	BRect,
25 	&BMessage::AddRect,
26 	&BMessage::FindRect,
27 	&BMessage::FindRect,
28 	&BMessage::FindRect,
29 	&BMessage::HasRect,
30 	&BMessage::ReplaceRect
31 >
32 TBRectFuncPolicy;
33 
34 struct TBRectInitPolicy : public ArrayTypeBase<BRect>
35 {
36 	inline static BRect Zero()		{ return BRect(0, 0, 0, 0); }
37 	inline static BRect Test1()	{ return BRect(1, 2, 3, 4); }
38 	inline static BRect Test2()	{ return BRect(5, 6, 7, 8); }
39 	inline static size_t SizeOf(const BRect&)	{ return sizeof (BRect); }
40 	inline static ArrayType Array()
41 	{
42 		ArrayType array;
43 		array.push_back(BRect(1, 2, 3, 4));
44 		array.push_back(BRect(4, 5, 6, 7));
45 		array.push_back(BRect(7, 8, 9, 10));
46 		return array;
47 	}
48 };
49 
50 struct TBRectAssertPolicy
51 {
52 	inline static BRect Zero() { return BRect(0, 0, 0, 0); }
53 	inline static BRect Invalid() { return BRect(0, 0, -1, -1); }
54 	inline static bool  Size(size_t size, BRect& r)
55 		{ return size == sizeof (r); }
56 };
57 
58 typedef TMessageItemTest
59 <
60 	BRect,
61 	B_RECT_TYPE,
62 	TBRectFuncPolicy,
63 	TBRectInitPolicy,
64 	TBRectAssertPolicy
65 >
66 TMessageBRectItemTest;
67 
68 std::ostream& operator<<(std::ostream& os, const BRect& rect)
69 {
70 	int precision = os.precision();
71 	os.precision(1);
72 	os << "rect"
73 	   << "(l:" << rect.left
74 	   << " t:" << rect.top
75 	   << " r:" << rect.right
76 	   << " b:" << rect.bottom
77 	   << ")";
78 	os.precision(precision);
79 
80 	return os;
81 }
82 
83 #endif	// MESSAGEBRECTITEMTEST_H
84 
85 /*
86  * $Log $
87  *
88  * $Id  $
89  *
90  */
91 
92