Adding BPropertyInfo tests to CVS.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@798 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
216921555f
commit
d081dee68d
187
src/tests/kits/app/bpropertyinfo/PropertyConstructionTest.cpp
Normal file
187
src/tests/kits/app/bpropertyinfo/PropertyConstructionTest.cpp
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
$Id: PropertyConstructionTest.cpp,v 1.1 2002/08/18 03:44:20 jrand Exp $
|
||||
|
||||
This file implements the construction test for the OpenBeOS BPropertyInfo
|
||||
code.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "PropertyConstructionTest.h"
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyConstructionTest::PropertyConstructionTest()
|
||||
* Descr: This is the constructor for this class.
|
||||
*/
|
||||
|
||||
|
||||
PropertyConstructionTest::PropertyConstructionTest(std::string name) :
|
||||
PropertyTestcase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyConstructionTest::~PropertyConstructionTest()
|
||||
* Descr: This is the destructor for this class.
|
||||
*/
|
||||
|
||||
|
||||
PropertyConstructionTest::~PropertyConstructionTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyConstructionTest::CompareProperties()
|
||||
* Descr: This member function checks that the two property_info structures
|
||||
* passed in match.
|
||||
*/
|
||||
|
||||
|
||||
void PropertyConstructionTest::CompareProperties(
|
||||
const property_info *prop1,
|
||||
const property_info *prop2,
|
||||
int prop_count)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
if ((prop_count != 0) && (prop1 != prop2)) {
|
||||
assert(prop1 != NULL);
|
||||
assert(prop2 != NULL);
|
||||
for (i = 0; i < prop_count; i++) {
|
||||
assert(prop1[i].name != 0);
|
||||
assert(prop2[i].name != 0);
|
||||
assert(strcmp(prop1[i].name, prop2[i].name) == 0);
|
||||
|
||||
for(j = 0; j < 10; j++) {
|
||||
assert(prop1[i].commands[j] == prop2[i].commands[j]);
|
||||
if (prop1[i].commands[j] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(j = 0; j < 10; j++) {
|
||||
assert(prop1[i].specifiers[j] == prop2[i].specifiers[j]);
|
||||
if (prop1[i].specifiers[j] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (prop1[i].usage != prop2[i].usage) {
|
||||
if (prop1[i].usage == NULL) {
|
||||
assert(prop2[i].usage == NULL);
|
||||
} else {
|
||||
assert(strcmp(prop1[i].usage, prop2[i].usage) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
assert(prop1[i].extra_data == prop2[i].extra_data);
|
||||
|
||||
for(j = 0; j < 10; j++) {
|
||||
assert(prop1[i].types[j] == prop2[i].types[j]);
|
||||
if (prop1[i].types[j] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(j = 0; j < 3; j++) {
|
||||
for(k = 0; k < 5; k++) {
|
||||
if (prop1[i].ctypes[j].pairs[k].name == 0) {
|
||||
assert(prop2[i].ctypes[j].pairs[k].name == 0);
|
||||
break;
|
||||
} else {
|
||||
assert(prop2[i].ctypes[j].pairs[k].name != 0);
|
||||
assert(strcmp(prop1[i].ctypes[j].pairs[k].name,
|
||||
prop2[i].ctypes[j].pairs[k].name) == 0);
|
||||
assert(prop1[i].ctypes[j].pairs[k].type ==
|
||||
prop2[i].ctypes[j].pairs[k].type);
|
||||
}
|
||||
}
|
||||
if (prop1[i].ctypes[j].pairs[0].name == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyConstructionTest::CompareValues()
|
||||
* Descr: This member function checks that the two value_info structures
|
||||
* passed in match.
|
||||
*/
|
||||
|
||||
|
||||
void PropertyConstructionTest::CompareValues(
|
||||
const value_info *value1,
|
||||
const value_info *value2,
|
||||
int value_count)
|
||||
{
|
||||
int i;
|
||||
if ((value_count != 0) && (value1 != value2)) {
|
||||
assert(value1 != NULL);
|
||||
assert(value2 != NULL);
|
||||
for (i = 0; i < value_count; i++) {
|
||||
assert(value1[i].name != 0);
|
||||
assert(value2[i].name != 0);
|
||||
assert(strcmp(value1[i].name, value2[i].name) == 0);
|
||||
|
||||
assert(value1[i].value == value2[i].value);
|
||||
|
||||
assert(value1[i].kind == value2[i].kind);
|
||||
|
||||
if (value1[i].usage == 0) {
|
||||
assert(value2[i].usage == 0);
|
||||
} else {
|
||||
assert(value2[i].usage != 0);
|
||||
assert(strcmp(value1[i].usage, value2[i].usage) == 0);
|
||||
}
|
||||
|
||||
assert(value1[i].extra_data == value2[i].extra_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyConstructionTest::TestProperty()
|
||||
* Descr: This member function performs this test.
|
||||
*/
|
||||
|
||||
|
||||
void PropertyConstructionTest::TestProperty(
|
||||
BPropertyInfo *propTest,
|
||||
const property_info *prop_list,
|
||||
const value_info *value_list,
|
||||
int32 prop_count,
|
||||
int32 value_count,
|
||||
ssize_t flat_size,
|
||||
const char *flat_data)
|
||||
{
|
||||
assert(propTest->CountProperties() == prop_count);
|
||||
assert(propTest->CountValues() == value_count);
|
||||
CompareProperties(propTest->Properties(), prop_list, prop_count);
|
||||
CompareValues(propTest->Values(), value_list, value_count);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyConstructionTest::suite()
|
||||
* Descr: This static member function returns a test caller for performing
|
||||
* all combinations of "PropertyConstructionTest". The test
|
||||
* is created as a ThreadedTestCase (typedef'd as
|
||||
* PropertyConstructionTestCaller) with only one thread.
|
||||
*/
|
||||
|
||||
Test *PropertyConstructionTest::suite(void)
|
||||
{
|
||||
typedef CppUnit::TestCaller<PropertyConstructionTest>
|
||||
PropertyConstructionTestCaller;
|
||||
|
||||
return(new PropertyConstructionTestCaller("BPropertyInfo::Construction Test", &PropertyConstructionTest::PerformTest));
|
||||
}
|
||||
|
||||
|
44
src/tests/kits/app/bpropertyinfo/PropertyConstructionTest.h
Normal file
44
src/tests/kits/app/bpropertyinfo/PropertyConstructionTest.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
$Id: PropertyConstructionTest.h,v 1.1 2002/08/18 03:44:21 jrand Exp $
|
||||
|
||||
This file defines a class for performing one test of BPropertyInfo
|
||||
functionality.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PropertyConstructionTest_H
|
||||
#define PropertyConstructionTest_H
|
||||
|
||||
|
||||
#include "PropertyTestcase.h"
|
||||
#include <PropertyInfo.h>
|
||||
|
||||
|
||||
class PropertyConstructionTest :
|
||||
public PropertyTestcase {
|
||||
|
||||
private:
|
||||
void CompareProperties(const property_info *prop1,
|
||||
const property_info *prop2,
|
||||
int prop_count);
|
||||
void CompareValues(const value_info *value1,
|
||||
const value_info *value2,
|
||||
int value_count);
|
||||
|
||||
protected:
|
||||
void TestProperty(BPropertyInfo *propTest,
|
||||
const property_info *prop_list,
|
||||
const value_info *value_list,
|
||||
int32 prop_count,
|
||||
int32 value_count,
|
||||
ssize_t flat_size,
|
||||
const char *flat_data);
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
PropertyConstructionTest(std::string name = "");
|
||||
virtual ~PropertyConstructionTest();
|
||||
};
|
||||
|
||||
#endif
|
169
src/tests/kits/app/bpropertyinfo/PropertyFindMatchTest.cpp
Normal file
169
src/tests/kits/app/bpropertyinfo/PropertyFindMatchTest.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
$Id: PropertyFindMatchTest.cpp,v 1.1 2002/08/18 03:44:21 jrand Exp $
|
||||
|
||||
This file implements the FindMatch test for the OpenBeOS BPropertyInfo
|
||||
code.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "PropertyFindMatchTest.h"
|
||||
#include <Message.h>
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFindMatchTest::PropertyFindMatchTest()
|
||||
* Descr: This is the constructor for this class.
|
||||
*/
|
||||
|
||||
|
||||
PropertyFindMatchTest::PropertyFindMatchTest(std::string name) :
|
||||
PropertyTestcase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFindMatchTest::~PropertyFindMatchTest()
|
||||
* Descr: This is the destructor for this class.
|
||||
*/
|
||||
|
||||
|
||||
PropertyFindMatchTest::~PropertyFindMatchTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFindMatchTest::TestProperty()
|
||||
* Descr: This member function performs this test.
|
||||
*/
|
||||
|
||||
|
||||
void PropertyFindMatchTest::TestProperty(
|
||||
BPropertyInfo *propTest,
|
||||
const property_info *prop_list,
|
||||
const value_info *value_list,
|
||||
int32 prop_count,
|
||||
int32 value_count,
|
||||
ssize_t flat_size,
|
||||
const char *flat_data)
|
||||
{
|
||||
const uint32 *commands;
|
||||
const uint32 *specifiers;
|
||||
const property_info *theProps = propTest->Properties();
|
||||
int i, j, k;
|
||||
bool wildcardCommand, wildcardSpec;
|
||||
|
||||
ExecFindMatch(propTest, uniquePropName, uniqueCommand, uniqueSpecifier, false, -1);
|
||||
ExecFindMatch(propTest, commonPropName, uniqueCommand, uniqueSpecifier, false, -1);
|
||||
ExecFindMatch(propTest, uniquePropName, commonCommand, uniqueSpecifier, false, -1);
|
||||
ExecFindMatch(propTest, uniquePropName, uniqueCommand, commonSpecifier, false, -1);
|
||||
|
||||
for (i=0; i < prop_count; i++) {
|
||||
wildcardCommand = (theProps[i].commands[0] == 0);
|
||||
wildcardSpec = (theProps[i].specifiers[0] == 0);
|
||||
if (wildcardCommand) {
|
||||
commands = wildcardCommandTests;
|
||||
} else {
|
||||
commands = theProps[i].commands;
|
||||
}
|
||||
if (wildcardSpec) {
|
||||
specifiers = wildcardSpecifierTests;
|
||||
} else {
|
||||
specifiers = theProps[i].specifiers;
|
||||
}
|
||||
for(j=0; j<10; j++) {
|
||||
if (commands[j] == 0) {
|
||||
break;
|
||||
}
|
||||
if (!wildcardSpec) {
|
||||
ExecFindMatch(propTest, theProps[i].name, commands[j], uniqueSpecifier,
|
||||
wildcardCommand, -1);
|
||||
}
|
||||
for(k=0; k<10; k++) {
|
||||
if (specifiers[k] == 0) {
|
||||
break;
|
||||
}
|
||||
if (!wildcardCommand) {
|
||||
ExecFindMatch(propTest, theProps[i].name, uniqueCommand, specifiers[k],
|
||||
wildcardCommand, -1);
|
||||
}
|
||||
ExecFindMatch(propTest, theProps[i].name, commands[j], specifiers[k],
|
||||
wildcardCommand, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFindMatchTest::ExecFindMatch()
|
||||
* Descr: This member function executes the FindMatch() member on the
|
||||
* BPropertyInfo instance and ensures that the result is what is
|
||||
* expected. It calls FindMatch() normally with a zero index
|
||||
* (meaning to match wildcard and non-wildcard command instances)
|
||||
* and with a non-NULL specifier message. The extra_data member
|
||||
* is checked to make sure it is what is expected if a match is
|
||||
* returned.
|
||||
*
|
||||
* The Be implementation takes a pointer to a BMessage specifier
|
||||
* but it doesn't seem to need it. So, the FindMatch() is called
|
||||
* again with a NULL BMessage specifier and we expect the same
|
||||
* result.
|
||||
*
|
||||
* Finally, the result is checked with a non-zero index. If index
|
||||
* is non-zero, a match will only be found if the property uses
|
||||
* a wildcard for the command. Depending on whether we are testing
|
||||
* a wildcard command (from the wildcardCommand flag), we check the
|
||||
* result with and without a BMessage specifier.
|
||||
*/
|
||||
|
||||
|
||||
void PropertyFindMatchTest::ExecFindMatch(
|
||||
BPropertyInfo *propTest,
|
||||
const char *prop,
|
||||
uint32 comm,
|
||||
uint32 spec,
|
||||
bool wildcardCommand,
|
||||
int32 result
|
||||
)
|
||||
{
|
||||
BMessage msg(comm);
|
||||
BMessage specMsg(spec);
|
||||
specMsg.AddString("property", prop);
|
||||
msg.AddSpecifier(&specMsg);
|
||||
uint32 extra_data;
|
||||
|
||||
assert(propTest->FindMatch(&msg, 0, &specMsg, spec, prop, &extra_data) == result);
|
||||
if (result >= 0) {
|
||||
assert((propTest->Properties())[result].extra_data == extra_data);
|
||||
}
|
||||
assert(propTest->FindMatch(&msg, 0, NULL, spec, prop, &extra_data) == result);
|
||||
if (wildcardCommand) {
|
||||
assert(propTest->FindMatch(&msg, 1, &specMsg, spec, prop, &extra_data) == result);
|
||||
assert(propTest->FindMatch(&msg, 1, NULL, spec, prop, &extra_data) == result);
|
||||
} else {
|
||||
assert(propTest->FindMatch(&msg, 1, &specMsg, spec, prop, &extra_data) == -1);
|
||||
assert(propTest->FindMatch(&msg, 1, NULL, spec, prop, &extra_data) == -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFindMatchTest::suite()
|
||||
* Descr: This static member function returns a test caller for performing
|
||||
* all combinations of "PropertyFindMatchTest". The test
|
||||
* is created as a ThreadedTestCase (typedef'd as
|
||||
* PropertyFindMatchTestCaller) with only one thread.
|
||||
*/
|
||||
|
||||
Test *PropertyFindMatchTest::suite(void)
|
||||
{
|
||||
typedef CppUnit::TestCaller<PropertyFindMatchTest>
|
||||
PropertyFindMatchTestCaller;
|
||||
|
||||
return(new PropertyFindMatchTestCaller("BPropertyInfo::FindMatch Test", &PropertyFindMatchTest::PerformTest));
|
||||
}
|
||||
|
||||
|
44
src/tests/kits/app/bpropertyinfo/PropertyFindMatchTest.h
Normal file
44
src/tests/kits/app/bpropertyinfo/PropertyFindMatchTest.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
$Id: PropertyFindMatchTest.h,v 1.1 2002/08/18 03:44:21 jrand Exp $
|
||||
|
||||
This file defines a class for performing one test of BPropertyInfo
|
||||
functionality.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PropertyFindMatchTest_H
|
||||
#define PropertyFindMatchTest_H
|
||||
|
||||
|
||||
#include "PropertyTestcase.h"
|
||||
#include <PropertyInfo.h>
|
||||
|
||||
|
||||
class PropertyFindMatchTest :
|
||||
public PropertyTestcase {
|
||||
|
||||
private:
|
||||
void ExecFindMatch(BPropertyInfo *propTest,
|
||||
const char *prop,
|
||||
uint32 comm,
|
||||
uint32 spec,
|
||||
bool wildcardCommand,
|
||||
int32 result);
|
||||
|
||||
protected:
|
||||
void TestProperty(BPropertyInfo *propTest,
|
||||
const property_info *prop_list,
|
||||
const value_info *value_list,
|
||||
int32 prop_count,
|
||||
int32 value_count,
|
||||
ssize_t flat_size,
|
||||
const char *flat_data);
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
PropertyFindMatchTest(std::string name = "");
|
||||
virtual ~PropertyFindMatchTest();
|
||||
};
|
||||
|
||||
#endif
|
71
src/tests/kits/app/bpropertyinfo/PropertyFlattenTest.cpp
Normal file
71
src/tests/kits/app/bpropertyinfo/PropertyFlattenTest.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
$Id: PropertyFlattenTest.cpp,v 1.1 2002/08/18 03:44:21 jrand Exp $
|
||||
|
||||
This file implements the flatten test for the OpenBeOS BPropertyInfo code.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "PropertyFlattenTest.h"
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFlattenTest::PropertyFlattenTest()
|
||||
* Descr: This is the constructor for this class.
|
||||
*/
|
||||
|
||||
PropertyFlattenTest::PropertyFlattenTest(std::string name) :
|
||||
PropertyTestcase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFlattenTest::~PropertyFlattenTest()
|
||||
* Descr: This is the destructor for this class.
|
||||
*/
|
||||
|
||||
PropertyFlattenTest::~PropertyFlattenTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFlattenTest::TestProperty()
|
||||
* Descr: This member function performs this test.
|
||||
*/
|
||||
|
||||
void PropertyFlattenTest::TestProperty(
|
||||
BPropertyInfo *propTest,
|
||||
const property_info *prop_list,
|
||||
const value_info *value_list,
|
||||
int32 prop_count,
|
||||
int32 value_count,
|
||||
ssize_t flat_size,
|
||||
const char *flat_data)
|
||||
{
|
||||
char buffer[768];
|
||||
|
||||
assert(!propTest->IsFixedSize());
|
||||
assert(propTest->TypeCode() == B_PROPERTY_INFO_TYPE);
|
||||
assert(propTest->AllowsTypeCode(B_PROPERTY_INFO_TYPE));
|
||||
assert(!propTest->AllowsTypeCode(B_TIME_TYPE));
|
||||
assert(propTest->FlattenedSize() == flat_size);
|
||||
assert(propTest->Flatten(buffer, sizeof(buffer)/ sizeof(buffer[0])) == B_OK);
|
||||
assert(memcmp(buffer, flat_data, propTest->FlattenedSize()) == 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyFlattenTest::suite()
|
||||
* Descr: This static member function returns a test caller for performing
|
||||
* all combinations of "PropertyFlattenTest".
|
||||
*/
|
||||
|
||||
Test *PropertyFlattenTest::suite(void)
|
||||
{
|
||||
typedef CppUnit::TestCaller<PropertyFlattenTest>
|
||||
PropertyFlattenTestCaller;
|
||||
|
||||
return(new PropertyFlattenTestCaller("BPropertyInfo::Flatten Test", &PropertyFlattenTest::PerformTest));
|
||||
}
|
36
src/tests/kits/app/bpropertyinfo/PropertyFlattenTest.h
Normal file
36
src/tests/kits/app/bpropertyinfo/PropertyFlattenTest.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
$Id: PropertyFlattenTest.h,v 1.1 2002/08/18 03:44:21 jrand Exp $
|
||||
|
||||
This file defines a class for performing one test of BPropertyInfo
|
||||
functionality.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PropertyFlattenTest_H
|
||||
#define PropertyFlattenTest_H
|
||||
|
||||
|
||||
#include "PropertyTestcase.h"
|
||||
#include <PropertyInfo.h>
|
||||
|
||||
|
||||
class PropertyFlattenTest :
|
||||
public PropertyTestcase {
|
||||
|
||||
protected:
|
||||
void TestProperty(BPropertyInfo *propTest,
|
||||
const property_info *prop_list,
|
||||
const value_info *value_list,
|
||||
int32 prop_count,
|
||||
int32 value_count,
|
||||
ssize_t flat_size,
|
||||
const char *flat_data);
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
PropertyFlattenTest(std::string name = "");
|
||||
virtual ~PropertyFlattenTest();
|
||||
};
|
||||
|
||||
#endif
|
426
src/tests/kits/app/bpropertyinfo/PropertyTestcase.cpp
Normal file
426
src/tests/kits/app/bpropertyinfo/PropertyTestcase.cpp
Normal file
@ -0,0 +1,426 @@
|
||||
/*
|
||||
$Id: PropertyTestcase.cpp,v 1.1 2002/08/18 03:44:21 jrand Exp $
|
||||
|
||||
This file implements the first test for the OpenBeOS BPropertyInfo code.
|
||||
It tests the Construction use cases. It does so by doing the following:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "PropertyTestcase.h"
|
||||
#include <AppDefs.h>
|
||||
#include <Message.h>
|
||||
|
||||
|
||||
/* The following constants define unique values (values which are not used
|
||||
in the BPropertyInfo instances constructed) and common values (values
|
||||
which are likely to match in BPropertyInfo instances). The wildcard
|
||||
tests list commands or specifiers to check for when a particular property
|
||||
has a command or specifier wildcard. */
|
||||
|
||||
const char *PropertyTestcase::uniquePropName = "no match!";
|
||||
const uint32 PropertyTestcase::uniqueCommand = 11;
|
||||
const uint32 PropertyTestcase::uniqueSpecifier = 11;
|
||||
const char *PropertyTestcase::commonPropName = "test1";
|
||||
const uint32 PropertyTestcase::commonCommand = B_GET_PROPERTY;
|
||||
const uint32 PropertyTestcase::commonSpecifier = B_DIRECT_SPECIFIER;
|
||||
const uint32 PropertyTestcase::wildcardCommandTests[] = { uniqueCommand,
|
||||
commonCommand,
|
||||
0};
|
||||
const uint32 PropertyTestcase::wildcardSpecifierTests[] = { uniqueSpecifier,
|
||||
commonSpecifier,
|
||||
0};
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyTestcase::PropertyTestcase()
|
||||
* Descr: This is the constructor for this class.
|
||||
*/
|
||||
|
||||
|
||||
PropertyTestcase::PropertyTestcase(std::string name) :
|
||||
TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyTestcase::~PropertyTestcase()
|
||||
* Descr: This is the destructor for this class.
|
||||
*/
|
||||
|
||||
|
||||
PropertyTestcase::~PropertyTestcase()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyTestcase::DuplicateProperties()
|
||||
* Descr: This member function returns a pointer to a malloc()'d
|
||||
* property_info structure which is a copy of the one passed
|
||||
* in.
|
||||
*/
|
||||
|
||||
|
||||
property_info *PropertyTestcase::DuplicateProperties(
|
||||
const property_info *prop1,
|
||||
int prop_count)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
property_info *prop2 = NULL;
|
||||
if (prop1 != NULL) {
|
||||
prop2 = (property_info *) malloc(sizeof(property_info) * (prop_count + 1));
|
||||
memcpy(prop2, prop1, sizeof(property_info) * (prop_count + 1));
|
||||
for(i = 0; i < prop_count; i++) {
|
||||
if (prop1[i].name != NULL) {
|
||||
prop2[i].name = strdup(prop1[i].name);
|
||||
}
|
||||
if (prop1[i].usage != NULL) {
|
||||
prop2[i].usage = strdup(prop1[i].usage);
|
||||
}
|
||||
for(j = 0; j < 3; j++) {
|
||||
for(k = 0; k < 5; k++) {
|
||||
if (prop1[i].ctypes[j].pairs[k].name == NULL) {
|
||||
break;
|
||||
} else {
|
||||
prop2[i].ctypes[j].pairs[k].name =
|
||||
strdup(prop1[i].ctypes[j].pairs[k].name);
|
||||
}
|
||||
}
|
||||
if (prop1[i].ctypes[j].pairs[0].name == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(prop2);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyTestcase::DuplicateValues()
|
||||
* Descr: This member function returns a pointer to a malloc()'d
|
||||
* value_info structure which is a copy of the one passed
|
||||
* in.
|
||||
*/
|
||||
|
||||
|
||||
value_info *PropertyTestcase::DuplicateValues(
|
||||
const value_info *value1,
|
||||
int value_count)
|
||||
{
|
||||
int i;
|
||||
|
||||
value_info *value2 = NULL;
|
||||
if (value1 != NULL) {
|
||||
value2 = (value_info *) malloc(sizeof(value_info) * (value_count + 1));
|
||||
memcpy(value2, value1, sizeof(value_info) * (value_count + 1));
|
||||
for(i = 0; i < value_count; i++) {
|
||||
if (value1[i].name != NULL) {
|
||||
value2[i].name = strdup(value1[i].name);
|
||||
}
|
||||
if (value1[i].usage != NULL) {
|
||||
value2[i].usage = strdup(value1[i].usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(value2);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: PropertyTestcase::PerformTest()
|
||||
* Descr: This member function creates 27 different BPropertyInfo
|
||||
* instances and then passes each of them to TestProperty().
|
||||
* The actual instances are:
|
||||
* - NULL property_info, NULL value_info
|
||||
* - NULL property_info, empty value_info
|
||||
* - NULL property_info, sample value_info
|
||||
* - empty property_info, NULL value_info
|
||||
* - empty property_info, empty value_info
|
||||
* - empty property_info, sample value_info
|
||||
* - sample property_info, NULL value_info
|
||||
* - sample property_info, empty value_info
|
||||
* - sample property_info, sample value_info
|
||||
* Each of these are created in three different ways:
|
||||
* - one where each structure is statically allocated
|
||||
* - one where each structure is dynamically allocated
|
||||
* - one where the BPropertyInfo is unflattened
|
||||
* This results in 27 different combinations to perform tests
|
||||
* on.
|
||||
*/
|
||||
|
||||
|
||||
void PropertyTestcase::PerformTest(void)
|
||||
{
|
||||
typedef struct property_tests {
|
||||
struct property_info *props;
|
||||
struct value_info *values;
|
||||
int prop_count;
|
||||
int value_count;
|
||||
int flat_size;
|
||||
char flat_data[768];
|
||||
} property_tests;
|
||||
|
||||
struct property_info prop1[] = { 0 };
|
||||
struct property_info prop2[] = {
|
||||
{ "test1", {B_GET_PROPERTY, B_SET_PROPERTY, B_EXECUTE_PROPERTY,
|
||||
B_DELETE_PROPERTY, B_CREATE_PROPERTY, B_COUNT_PROPERTIES, 7,
|
||||
8, 9, 10},
|
||||
{B_DIRECT_SPECIFIER, B_NAME_SPECIFIER, B_ID_SPECIFIER,
|
||||
B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER,
|
||||
B_RANGE_SPECIFIER, B_REVERSE_RANGE_SPECIFIER, 8, 9, 10},
|
||||
"test1: Test maximum property_info",
|
||||
0,
|
||||
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{
|
||||
{ { {"ctype11", 11}, {"ctype12", 12}, {"ctype13", 13},
|
||||
{"ctype14", 14}, {"ctype15", 15} } },
|
||||
{ { {"ctype21", 21}, {"ctype22", 22}, {"ctype23", 23},
|
||||
{"ctype24", 24}, {"ctype25", 25} } },
|
||||
{ { {"ctype31", 31}, {"ctype32", 32}, {"ctype33", 33},
|
||||
{"ctype34", 34}, {"ctype35", 35} } } }
|
||||
},
|
||||
{ "test2", {0, B_GET_PROPERTY},
|
||||
{B_DIRECT_SPECIFIER, 0},
|
||||
"test2: Test wildcard command",
|
||||
1},
|
||||
{ "test3", {B_GET_PROPERTY, 0},
|
||||
{0, B_DIRECT_SPECIFIER},
|
||||
"test3: Test wildcard specifier",
|
||||
2},
|
||||
{ "test4", {0, B_GET_PROPERTY},
|
||||
{0, B_DIRECT_SPECIFIER},
|
||||
"test4: Test wildcard command and specifier",
|
||||
3},
|
||||
0 // terminate list
|
||||
};
|
||||
|
||||
struct value_info value1[] = { 0 };
|
||||
struct value_info value2[] = {
|
||||
{ "Value1", 5, B_COMMAND_KIND, "This is the usage", 0 },
|
||||
{ "Value2", 6, B_TYPE_CODE_KIND, "This is the usage", 1 },
|
||||
0 // terminate list
|
||||
};
|
||||
|
||||
property_tests theTests[] = {
|
||||
{ NULL, NULL, 0, 0, 9,
|
||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0}
|
||||
},
|
||||
{ NULL, value1, 0, 0, 11,
|
||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0}
|
||||
},
|
||||
{ NULL, value2, 0, 2, 85,
|
||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31,
|
||||
0x0, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x1, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x56, 0x61, 0x6c, 0x75,
|
||||
0x65, 0x32, 0x0, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
|
||||
0x74, 0x68, 0x65, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x0, 0x1,
|
||||
0x0, 0x0, 0x0}
|
||||
},
|
||||
{ prop1, NULL, 0, 0, 9,
|
||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0}
|
||||
},
|
||||
{ prop1, value1, 0, 0, 11,
|
||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0}
|
||||
},
|
||||
{ prop1, value2, 0, 2, 85,
|
||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31,
|
||||
0x0, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x1, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x56, 0x61, 0x6c, 0x75,
|
||||
0x65, 0x32, 0x0, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
|
||||
0x74, 0x68, 0x65, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x0, 0x1,
|
||||
0x0, 0x0, 0x0}
|
||||
},
|
||||
{ prop2, NULL, 4, 0, 570,
|
||||
{0x0, 0x4, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x74, 0x65, 0x73,
|
||||
0x74, 0x31, 0x0, 0x74, 0x65, 0x73, 0x74, 0x31, 0x3a, 0x20, 0x54,
|
||||
0x65, 0x73, 0x74, 0x20, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d,
|
||||
0x20, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x5f, 0x69,
|
||||
0x6e, 0x66, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x54, 0x45, 0x47, 0x50,
|
||||
0x54, 0x45, 0x53, 0x50, 0x45, 0x58, 0x45, 0x50, 0x4c, 0x45, 0x44,
|
||||
0x50, 0x54, 0x52, 0x43, 0x50, 0x54, 0x4e, 0x43, 0x50, 0x7, 0x0,
|
||||
0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0,
|
||||
0x7, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4,
|
||||
0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x9, 0x0,
|
||||
0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x65,
|
||||
0x73, 0x74, 0x32, 0x0, 0x74, 0x65, 0x73, 0x74, 0x32, 0x3a, 0x20,
|
||||
0x54, 0x65, 0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61,
|
||||
0x72, 0x64, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x0,
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x74, 0x65, 0x73, 0x74, 0x33, 0x0, 0x74, 0x65, 0x73,
|
||||
0x74, 0x33, 0x3a, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x77, 0x69,
|
||||
0x6c, 0x64, 0x63, 0x61, 0x72, 0x64, 0x20, 0x73, 0x70, 0x65, 0x63,
|
||||
0x69, 0x66, 0x69, 0x65, 0x72, 0x0, 0x2, 0x0, 0x0, 0x0, 0x54, 0x45,
|
||||
0x47, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x65,
|
||||
0x73, 0x74, 0x34, 0x0, 0x74, 0x65, 0x73, 0x74, 0x34, 0x3a, 0x20,
|
||||
0x54, 0x65, 0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61,
|
||||
0x72, 0x64, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20,
|
||||
0x61, 0x6e, 0x64, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69,
|
||||
0x65, 0x72, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0,
|
||||
0x0, 0x4, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0,
|
||||
0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0xa,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65,
|
||||
0x31, 0x31, 0x0, 0xb, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65,
|
||||
0x31, 0x32, 0x0, 0xc, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65,
|
||||
0x31, 0x33, 0x0, 0xd, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65,
|
||||
0x31, 0x34, 0x0, 0xe, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65,
|
||||
0x31, 0x35, 0x0, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x63,
|
||||
0x74, 0x79, 0x70, 0x65, 0x32, 0x31, 0x0, 0x15, 0x0, 0x0, 0x0, 0x63,
|
||||
0x74, 0x79, 0x70, 0x65, 0x32, 0x32, 0x0, 0x16, 0x0, 0x0, 0x0, 0x63,
|
||||
0x74, 0x79, 0x70, 0x65, 0x32, 0x33, 0x0, 0x17, 0x0, 0x0, 0x0, 0x63,
|
||||
0x74, 0x79, 0x70, 0x65, 0x32, 0x34, 0x0, 0x18, 0x0, 0x0, 0x0, 0x63,
|
||||
0x74, 0x79, 0x70, 0x65, 0x32, 0x35, 0x0, 0x19, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x31, 0x0, 0x1f,
|
||||
0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x32, 0x0, 0x20,
|
||||
0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x33, 0x0, 0x21,
|
||||
0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x34, 0x0, 0x22,
|
||||
0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x35, 0x0, 0x23,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
|
||||
},
|
||||
{ prop2, value1, 4, 0, 572,
|
||||
{0x0, 0x4, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x74, 0x65, 0x73, 0x74,
|
||||
0x31, 0x0, 0x74, 0x65, 0x73, 0x74, 0x31, 0x3a, 0x20, 0x54, 0x65,
|
||||
0x73, 0x74, 0x20, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20,
|
||||
0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x5f, 0x69, 0x6e,
|
||||
0x66, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x54, 0x45, 0x47, 0x50, 0x54,
|
||||
0x45, 0x53, 0x50, 0x45, 0x58, 0x45, 0x50, 0x4c, 0x45, 0x44, 0x50,
|
||||
0x54, 0x52, 0x43, 0x50, 0x54, 0x4e, 0x43, 0x50, 0x7, 0x0, 0x0, 0x0,
|
||||
0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x7, 0x0,
|
||||
0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0,
|
||||
0x0, 0x5, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0,
|
||||
0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x65, 0x73, 0x74,
|
||||
0x32, 0x0, 0x74, 0x65, 0x73, 0x74, 0x32, 0x3a, 0x20, 0x54, 0x65,
|
||||
0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64,
|
||||
0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x0, 0x1, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x74, 0x65, 0x73, 0x74, 0x33, 0x0, 0x74, 0x65, 0x73, 0x74, 0x33,
|
||||
0x3a, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64,
|
||||
0x63, 0x61, 0x72, 0x64, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66,
|
||||
0x69, 0x65, 0x72, 0x0, 0x2, 0x0, 0x0, 0x0, 0x54, 0x45, 0x47, 0x50,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x65, 0x73, 0x74,
|
||||
0x34, 0x0, 0x74, 0x65, 0x73, 0x74, 0x34, 0x3a, 0x20, 0x54, 0x65,
|
||||
0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64,
|
||||
0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x6e,
|
||||
0x64, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x72,
|
||||
0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4,
|
||||
0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x7, 0x0,
|
||||
0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x31,
|
||||
0x0, 0xb, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x32,
|
||||
0x0, 0xc, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x33,
|
||||
0x0, 0xd, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x34,
|
||||
0x0, 0xe, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x35,
|
||||
0x0, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x31, 0x0, 0x15, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x32, 0x0, 0x16, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x33, 0x0, 0x17, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x34, 0x0, 0x18, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x35, 0x0, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x31, 0x0, 0x1f, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x32, 0x0, 0x20, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x33, 0x0, 0x21, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x34, 0x0, 0x22, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x35, 0x0, 0x23, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
|
||||
},
|
||||
{ prop2, value2, 4, 2, 646,
|
||||
{0x0, 0x4, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x74, 0x65, 0x73, 0x74,
|
||||
0x31, 0x0, 0x74, 0x65, 0x73, 0x74, 0x31, 0x3a, 0x20, 0x54, 0x65,
|
||||
0x73, 0x74, 0x20, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20,
|
||||
0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x5f, 0x69, 0x6e,
|
||||
0x66, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x54, 0x45, 0x47, 0x50, 0x54,
|
||||
0x45, 0x53, 0x50, 0x45, 0x58, 0x45, 0x50, 0x4c, 0x45, 0x44, 0x50,
|
||||
0x54, 0x52, 0x43, 0x50, 0x54, 0x4e, 0x43, 0x50, 0x7, 0x0, 0x0, 0x0,
|
||||
0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x7, 0x0,
|
||||
0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0,
|
||||
0x0, 0x5, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0,
|
||||
0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x65, 0x73, 0x74,
|
||||
0x32, 0x0, 0x74, 0x65, 0x73, 0x74, 0x32, 0x3a, 0x20, 0x54, 0x65,
|
||||
0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64,
|
||||
0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x0, 0x1, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x74, 0x65, 0x73, 0x74, 0x33, 0x0, 0x74, 0x65, 0x73, 0x74, 0x33,
|
||||
0x3a, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64,
|
||||
0x63, 0x61, 0x72, 0x64, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66,
|
||||
0x69, 0x65, 0x72, 0x0, 0x2, 0x0, 0x0, 0x0, 0x54, 0x45, 0x47, 0x50,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74, 0x65, 0x73, 0x74,
|
||||
0x34, 0x0, 0x74, 0x65, 0x73, 0x74, 0x34, 0x3a, 0x20, 0x54, 0x65,
|
||||
0x73, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64,
|
||||
0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x6e,
|
||||
0x64, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x72,
|
||||
0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4,
|
||||
0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x7, 0x0,
|
||||
0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x31,
|
||||
0x0, 0xb, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x32,
|
||||
0x0, 0xc, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x33,
|
||||
0x0, 0xd, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x34,
|
||||
0x0, 0xe, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70, 0x65, 0x31, 0x35,
|
||||
0x0, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x31, 0x0, 0x15, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x32, 0x0, 0x16, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x33, 0x0, 0x17, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x34, 0x0, 0x18, 0x0, 0x0, 0x0, 0x63, 0x74, 0x79, 0x70,
|
||||
0x65, 0x32, 0x35, 0x0, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x31, 0x0, 0x1f, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x32, 0x0, 0x20, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x33, 0x0, 0x21, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x34, 0x0, 0x22, 0x0, 0x0, 0x0,
|
||||
0x63, 0x74, 0x79, 0x70, 0x65, 0x33, 0x35, 0x0, 0x23, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5,
|
||||
0x0, 0x0, 0x0, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x0, 0x54, 0x68,
|
||||
0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x75,
|
||||
0x73, 0x61, 0x67, 0x65, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,
|
||||
0x6, 0x0, 0x0, 0x0, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0x0, 0x54,
|
||||
0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20,
|
||||
0x75, 0x73, 0x61, 0x67, 0x65, 0x0, 0x1, 0x0, 0x0, 0x0}
|
||||
}
|
||||
};
|
||||
int i;
|
||||
BPropertyInfo *propTest;
|
||||
property_info *propPtr;
|
||||
value_info *valuePtr;
|
||||
|
||||
for (i=0; i < sizeof(theTests) / sizeof(theTests[0]); i++) {
|
||||
propTest = new BPropertyInfo(theTests[i].props, theTests[i].values);
|
||||
TestProperty(propTest, theTests[i].props, theTests[i].values,
|
||||
theTests[i].prop_count, theTests[i].value_count,
|
||||
theTests[i].flat_size, theTests[i].flat_data);
|
||||
delete propTest;
|
||||
|
||||
propPtr = DuplicateProperties(theTests[i].props, theTests[i].prop_count);
|
||||
valuePtr = DuplicateValues(theTests[i].values, theTests[i].value_count);
|
||||
propTest = new BPropertyInfo(propPtr, valuePtr, true);
|
||||
TestProperty(propTest, theTests[i].props, theTests[i].values,
|
||||
theTests[i].prop_count, theTests[i].value_count,
|
||||
theTests[i].flat_size, theTests[i].flat_data);
|
||||
delete propTest;
|
||||
|
||||
propTest = new BPropertyInfo;
|
||||
assert(propTest->Unflatten(B_PROPERTY_INFO_TYPE, theTests[i].flat_data,
|
||||
theTests[i].flat_size) == B_OK);
|
||||
TestProperty(propTest, theTests[i].props, theTests[i].values,
|
||||
theTests[i].prop_count, theTests[i].value_count,
|
||||
theTests[i].flat_size, theTests[i].flat_data);
|
||||
delete propTest;
|
||||
}
|
||||
}
|
49
src/tests/kits/app/bpropertyinfo/PropertyTestcase.h
Normal file
49
src/tests/kits/app/bpropertyinfo/PropertyTestcase.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
$Id: PropertyTestcase.h,v 1.1 2002/08/18 03:44:21 jrand Exp $
|
||||
|
||||
This file defines a base class for performing all tests of BPropertyInfo
|
||||
functionality.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PropertyTestcase_H
|
||||
#define PropertyTestcase_H
|
||||
|
||||
|
||||
#include "../common.h"
|
||||
#include <PropertyInfo.h>
|
||||
|
||||
|
||||
class PropertyTestcase :
|
||||
public TestCase {
|
||||
|
||||
private:
|
||||
property_info *DuplicateProperties(const property_info *prop1, int prop_count);
|
||||
value_info *DuplicateValues(const value_info *value1, int value_count);
|
||||
|
||||
protected:
|
||||
virtual void TestProperty(BPropertyInfo *propTest,
|
||||
const property_info *prop_list,
|
||||
const value_info *value_list,
|
||||
int32 prop_count,
|
||||
int32 value_count,
|
||||
ssize_t flat_size,
|
||||
const char *flat_data) = 0;
|
||||
|
||||
static const char *uniquePropName;
|
||||
static const uint32 uniqueCommand;
|
||||
static const uint32 uniqueSpecifier;
|
||||
static const char *commonPropName;
|
||||
static const uint32 commonCommand;
|
||||
static const uint32 commonSpecifier;
|
||||
static const uint32 wildcardCommandTests[];
|
||||
static const uint32 wildcardSpecifierTests[];
|
||||
|
||||
public:
|
||||
void PerformTest(void);
|
||||
PropertyTestcase(std::string name = "");
|
||||
virtual ~PropertyTestcase();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user