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