Moving these tests into three different files for construction tests, flattening tests and findmatch tests.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@800 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
jrand 2002-08-18 03:47:09 +00:00
parent 25a9178631
commit 10f4de1259
2 changed files with 0 additions and 727 deletions

View File

@ -1,668 +0,0 @@
/*
$Id: PropertyConstructionTest1.cpp,v 1.7 2002/08/17 05:55:18 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 "PropertyConstructionTest1.h"
#include <PropertyInfo.h>
#include <AppDefs.h>
#include <Message.h>
#include <TypeConstants.h>
#include <stdio.h>
#include <string.h>
/*
* Method: PropertyConstructionTest1::PropertyConstructionTest1()
* Descr: This is the constructor for this class.
*/
PropertyConstructionTest1::PropertyConstructionTest1(std::string name) :
TestCase(name)
{
}
/*
* Method: PropertyConstructionTest1::~PropertyConstructionTest1()
* Descr: This is the destructor for this class.
*/
PropertyConstructionTest1::~PropertyConstructionTest1()
{
}
/*
* Method: PropertyConstructionTest1::setUp()
* Descr: This member function is called just prior to running the test.
*/
void PropertyConstructionTest1::setUp(void)
{
}
/*
* Method: PropertyConstructionTest1::DuplicateProperties()
* Descr: This member function performs this test.
*/
property_info *PropertyConstructionTest1::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: PropertyConstructionTest1::DuplicateValues()
* Descr: This member function performs this test.
*/
value_info *PropertyConstructionTest1::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: PropertyConstructionTest1::CompareProperties()
* Descr: This member function performs this test.
*/
void PropertyConstructionTest1::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: PropertyConstructionTest1::CompareValues()
* Descr: This member function performs this test.
*/
void PropertyConstructionTest1::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: PropertyConstructionTest1::CheckProperty()
* Descr: This member function performs this test.
*/
void PropertyConstructionTest1::CheckProperty(
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->CountProperties() == prop_count);
assert(propTest->CountValues() == value_count);
CompareProperties(propTest->Properties(), prop_list, prop_count);
CompareValues(propTest->Values(), value_list, value_count);
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: PropertyConstructionTest1::CheckFindMatch()
* Descr: This member function performs this test.
*/
void PropertyConstructionTest1::CheckFindMatch(
BPropertyInfo *propTest)
{
const char *uniquePropName = "no match!";
const uint32 uniqueCommand = 11;
const uint32 uniqueSpecifier = 11;
const char *commonPropName = "test1";
const uint32 commonCommand = B_GET_PROPERTY;
const uint32 commonSpecifier = B_DIRECT_SPECIFIER;
const uint32 wildcardCommandTests[] = { uniqueCommand, commonCommand, 0};
const uint32 wildcardSpecifierTests[] = { uniqueSpecifier, commonSpecifier, 0};
const uint32 *commands;
const uint32 *specifiers;
const property_info *theProps = propTest->Properties();
int prop_count = propTest->CountProperties();
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: PropertyConstructionTest1::ExecFindMatch()
* Descr: This member function performs this test.
*/
void PropertyConstructionTest1::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: PropertyConstructionTest1::PerformTest()
* Descr: This member function performs this test.
*/
void PropertyConstructionTest1::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, 0x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x0, 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,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c, 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);
CheckProperty(propTest, theTests[i].props, theTests[i].values,
theTests[i].prop_count, theTests[i].value_count,
theTests[i].flat_size, theTests[i].flat_data);
CheckFindMatch(propTest);
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);
CheckProperty(propTest, theTests[i].props, theTests[i].values,
theTests[i].prop_count, theTests[i].value_count,
theTests[i].flat_size, theTests[i].flat_data);
CheckFindMatch(propTest);
delete propTest;
propTest = new BPropertyInfo;
assert(propTest->Unflatten(B_PROPERTY_INFO_TYPE, theTests[i].flat_data,
theTests[i].flat_size) == B_OK);
CheckProperty(propTest, theTests[i].props, theTests[i].values,
theTests[i].prop_count, theTests[i].value_count,
theTests[i].flat_size, theTests[i].flat_data);
CheckFindMatch(propTest);
delete propTest;
}
}
/*
* Method: PropertyConstructionTest1::suite()
* Descr: This static member function returns a test caller for performing
* all combinations of "PropertyConstructionTest1". The test
* is created as a ThreadedTestCase (typedef'd as
* PropertyConstructionTest1Caller) with only one thread.
*/
Test *PropertyConstructionTest1::suite(void)
{
typedef CppUnit::TestCaller<PropertyConstructionTest1>
PropertyConstructionTest1Caller;
return(new PropertyConstructionTest1Caller("BPropertyInfo::Construction Test", &PropertyConstructionTest1::PerformTest));
}

View File

@ -1,59 +0,0 @@
/*
$Id: PropertyConstructionTest1.h,v 1.5 2002/08/17 05:55:18 jrand Exp $
This file defines a class for performing one test of BPropertyInfo
functionality.
*/
#ifndef PropertyConstructionTest1_H
#define PropertyConstructionTest1_H
#include "../common.h"
#include <PropertyInfo.h>
class PropertyConstructionTest1 :
public TestCase {
private:
void CheckProperty(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);
void CheckFindMatch(BPropertyInfo *propTest);
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);
void ExecFindMatch(BPropertyInfo *propTest,
const char *prop,
uint32 comm,
uint32 spec,
bool wildcardCommand,
int32 result);
property_info *DuplicateProperties(const property_info *prop1, int prop_count);
value_info *DuplicateValues(const value_info *value1, int value_count);
public:
static Test *suite(void);
void setUp(void);
void PerformTest(void);
PropertyConstructionTest1(std::string name = "");
virtual ~PropertyConstructionTest1();
};
#endif