2 $Id: PropertyConstructionTest.cpp 851 2002-08-22 03:15:35Z jrand $
4 This file implements the construction test for the OpenBeOS BPropertyInfo
5 code. This class tests the following usecases:
17 #include "PropertyConstructionTest.h"
23 * Method: PropertyConstructionTest::PropertyConstructionTest()
24 * Descr: This is the constructor for this class.
28 PropertyConstructionTest::PropertyConstructionTest(std::string name
) :
29 PropertyTestcase(name
)
35 * Method: PropertyConstructionTest::~PropertyConstructionTest()
36 * Descr: This is the destructor for this class.
40 PropertyConstructionTest::~PropertyConstructionTest()
46 * Method: PropertyConstructionTest::CompareProperties()
47 * Descr: This member function checks that the two property_info structures
52 void PropertyConstructionTest::CompareProperties(
53 const property_info
*prop1
,
54 const property_info
*prop2
,
59 if ((prop_count
!= 0) && (prop1
!= prop2
)) {
60 assert(prop1
!= NULL
);
61 assert(prop2
!= NULL
);
62 for (i
= 0; i
< prop_count
; i
++) {
63 assert(prop1
[i
].name
!= 0);
64 assert(prop2
[i
].name
!= 0);
65 assert(strcmp(prop1
[i
].name
, prop2
[i
].name
) == 0);
67 for(j
= 0; j
< 10; j
++) {
68 assert(prop1
[i
].commands
[j
] == prop2
[i
].commands
[j
]);
69 if (prop1
[i
].commands
[j
] == 0) {
74 for(j
= 0; j
< 10; j
++) {
75 assert(prop1
[i
].specifiers
[j
] == prop2
[i
].specifiers
[j
]);
76 if (prop1
[i
].specifiers
[j
] == 0) {
81 if (prop1
[i
].usage
!= prop2
[i
].usage
) {
82 if (prop1
[i
].usage
== NULL
) {
83 assert(prop2
[i
].usage
== NULL
);
85 assert(strcmp(prop1
[i
].usage
, prop2
[i
].usage
) == 0);
89 assert(prop1
[i
].extra_data
== prop2
[i
].extra_data
);
91 for(j
= 0; j
< 10; j
++) {
92 assert(prop1
[i
].types
[j
] == prop2
[i
].types
[j
]);
93 if (prop1
[i
].types
[j
] == 0) {
98 for(j
= 0; j
< 3; j
++) {
99 for(k
= 0; k
< 5; k
++) {
100 if (prop1
[i
].ctypes
[j
].pairs
[k
].name
== 0) {
101 assert(prop2
[i
].ctypes
[j
].pairs
[k
].name
== 0);
104 assert(prop2
[i
].ctypes
[j
].pairs
[k
].name
!= 0);
105 assert(strcmp(prop1
[i
].ctypes
[j
].pairs
[k
].name
,
106 prop2
[i
].ctypes
[j
].pairs
[k
].name
) == 0);
107 assert(prop1
[i
].ctypes
[j
].pairs
[k
].type
==
108 prop2
[i
].ctypes
[j
].pairs
[k
].type
);
111 if (prop1
[i
].ctypes
[j
].pairs
[0].name
== 0) {
121 * Method: PropertyConstructionTest::CompareValues()
122 * Descr: This member function checks that the two value_info structures
127 void PropertyConstructionTest::CompareValues(
128 const value_info
*value1
,
129 const value_info
*value2
,
133 if ((value_count
!= 0) && (value1
!= value2
)) {
134 assert(value1
!= NULL
);
135 assert(value2
!= NULL
);
136 for (i
= 0; i
< value_count
; i
++) {
137 assert(value1
[i
].name
!= 0);
138 assert(value2
[i
].name
!= 0);
139 assert(strcmp(value1
[i
].name
, value2
[i
].name
) == 0);
141 assert(value1
[i
].value
== value2
[i
].value
);
143 assert(value1
[i
].kind
== value2
[i
].kind
);
145 if (value1
[i
].usage
== 0) {
146 assert(value2
[i
].usage
== 0);
148 assert(value2
[i
].usage
!= 0);
149 assert(strcmp(value1
[i
].usage
, value2
[i
].usage
) == 0);
152 assert(value1
[i
].extra_data
== value2
[i
].extra_data
);
159 * Method: PropertyConstructionTest::TestProperty()
160 * Descr: This member function performs this test.
164 void PropertyConstructionTest::TestProperty(
165 BPropertyInfo
*propTest
,
166 const property_info
*prop_list
,
167 const value_info
*value_list
,
171 const char *lflat_data
,
172 const char *bflat_data
)
174 assert(propTest
->CountProperties() == prop_count
);
175 assert(propTest
->CountValues() == value_count
);
176 CompareProperties(propTest
->Properties(), prop_list
, prop_count
);
177 CompareValues(propTest
->Values(), value_list
, value_count
);
182 * Method: PropertyConstructionTest::suite()
183 * Descr: This static member function returns a test caller for performing
184 * all combinations of "PropertyConstructionTest". The test
185 * is created as a ThreadedTestCase (typedef'd as
186 * PropertyConstructionTestCaller) with only one thread.
189 Test
*PropertyConstructionTest::suite(void)
191 typedef CppUnit::TestCaller
<PropertyConstructionTest
>
192 PropertyConstructionTestCaller
;
194 return(new PropertyConstructionTestCaller("BPropertyInfo::Construction Test", &PropertyConstructionTest::PerformTest
));