1 /* 2 $Id: PropertyFlattenTest.cpp 1218 2002-09-28 00:19:49Z shatty $ 3 4 This file implements the flatten test for the Haiku BPropertyInfo code. 5 This class tests the following usecases: 6 - Fixed Size 7 - Type Code 8 - Allows Type Code 9 - Flattened Size 10 - Flatten 11 12 */ 13 14 15 #include "PropertyFlattenTest.h" 16 17 #include <assert.h> 18 19 #include <ByteOrder.h> 20 21 22 /* 23 * Method: PropertyFlattenTest::PropertyFlattenTest() 24 * Descr: This is the constructor for this class. 25 */ 26 27 PropertyFlattenTest::PropertyFlattenTest(std::string name) : 28 PropertyTestcase(name) 29 { 30 } 31 32 33 /* 34 * Method: PropertyFlattenTest::~PropertyFlattenTest() 35 * Descr: This is the destructor for this class. 36 */ 37 38 PropertyFlattenTest::~PropertyFlattenTest() 39 { 40 } 41 42 43 /* 44 * Method: PropertyFlattenTest::TestProperty() 45 * Descr: This member function performs this test. 46 */ 47 48 void PropertyFlattenTest::TestProperty( 49 BPropertyInfo *propTest, 50 const property_info *prop_list, 51 const value_info *value_list, 52 int32 prop_count, 53 int32 value_count, 54 ssize_t flat_size, 55 const char *lflat_data, 56 const char *bflat_data) 57 { 58 char buffer[768]; 59 60 assert(!propTest->IsFixedSize()); 61 assert(propTest->TypeCode() == B_PROPERTY_INFO_TYPE); 62 assert(propTest->AllowsTypeCode(B_PROPERTY_INFO_TYPE)); 63 assert(!propTest->AllowsTypeCode(B_TIME_TYPE)); 64 assert(propTest->FlattenedSize() == flat_size); 65 assert(propTest->Flatten(buffer, sizeof(buffer)/ sizeof(buffer[0])) == B_OK); 66 if (B_HOST_IS_BENDIAN) { 67 assert(memcmp(buffer, bflat_data, propTest->FlattenedSize()) == 0); 68 } else { 69 assert(memcmp(buffer, lflat_data, propTest->FlattenedSize()) == 0); 70 } 71 } 72 73 74 /* 75 * Method: PropertyFlattenTest::suite() 76 * Descr: This static member function returns a test caller for performing 77 * all combinations of "PropertyFlattenTest". 78 */ 79 80 Test *PropertyFlattenTest::suite(void) 81 { 82 typedef CppUnit::TestCaller<PropertyFlattenTest> 83 PropertyFlattenTestCaller; 84 85 return(new PropertyFlattenTestCaller("BPropertyInfo::Flatten Test", &PropertyFlattenTest::PerformTest)); 86 } 87