Commit 87db953a authored by David Gobbi's avatar David Gobbi Committed by Kitware Robot
Browse files

Merge topic 'pointer-test-clang-warnings'

46216c38 COMP: Check the comparison results for vtkSmartPointer.
parents 22eebb13 46216c38
......@@ -23,38 +23,68 @@
int TestSmartPointer(int,char *[])
{
int rval = 0;
vtkIntArray* ia = vtkIntArray::New();
// Coverage:
unsigned int testbits = 0;
unsigned int correctbits = 0x004d3953;
const char *tests[] = {
"da2 == da3", "da2 != da3", "da2 < da3", "da2 <= da3", "da2 > da3",
"da2 >= da3",
"ia == da3", "ia != da3", "ia < da3", "ia <= da3", "ia > da3", "ia >= da3",
"da2 == ia", "da2 != ia", "da2 < ia", "da2 <= ia", "da2 > ia", "da2 <= ia",
"da2 > ia", "da2 >= ia",
"da1 == 0", "da1 != 0", "da1 < 0", "da1 <= 0", "da1 > 0", "da1 >= 0",
NULL };
vtkSmartPointer<vtkIntArray> da2(ia);
vtkSmartPointer<vtkFloatArray> da3;
vtkSmartPointer<vtkDataArray> da1(da2);
da1 = ia;
da1 = da2;
da2 == da3;
da2 != da3;
da2 < da3;
da2 <= da3;
da2 > da3;
da2 >= da3;
ia == da3;
ia != da3;
ia < da3;
ia <= da3;
ia > da3;
ia >= da3;
da2 == ia;
da2 != ia;
da2 < ia;
da2 <= ia;
da2 > ia;
da2 >= ia;
da1 == 0;
da1 != 0;
da1 < 0;
da1 <= 0;
da1 > 0;
da1 >= 0;
testbits = (testbits << 1) | (da2 == da3);
testbits = (testbits << 1) | (da2 != da3);
testbits = (testbits << 1) | (da2 < da3);
testbits = (testbits << 1) | (da2 <= da3);
testbits = (testbits << 1) | (da2 > da3);
testbits = (testbits << 1) | (da2 >= da3);
testbits = (testbits << 1) | (ia == da3);
testbits = (testbits << 1) | (ia != da3);
testbits = (testbits << 1) | (ia < da3);
testbits = (testbits << 1) | (ia <= da3);
testbits = (testbits << 1) | (ia > da3);
testbits = (testbits << 1) | (ia >= da3);
testbits = (testbits << 1) | (da2 == ia);
testbits = (testbits << 1) | (da2 != ia);
testbits = (testbits << 1) | (da2 < ia);
testbits = (testbits << 1) | (da2 <= ia);
testbits = (testbits << 1) | (da2 > ia);
testbits = (testbits << 1) | (da2 >= ia);
testbits = (testbits << 1) | (da1 == 0);
testbits = (testbits << 1) | (da1 != 0);
testbits = (testbits << 1) | (da1 < 0);
testbits = (testbits << 1) | (da1 <= 0);
testbits = (testbits << 1) | (da1 > 0);
testbits = (testbits << 1) | (da1 >= 0);
if (testbits != correctbits)
{
unsigned int diffbits = (testbits ^ correctbits);
int bitcount = 0;
while (tests[bitcount] != NULL)
{
bitcount++;
}
for (int ib = 0; ib < bitcount; ++ib)
{
if (((diffbits >> (bitcount - ib - 1)) & 1) != 0)
{
cerr << "comparison (" << tests[ib] << ") failed!\n";
}
}
rval = 1;
}
(*da1).SetNumberOfComponents(1);
if(da2)
{
......@@ -63,7 +93,7 @@ int TestSmartPointer(int,char *[])
if(!da2)
{
cerr << "da2 is NULL!" << "\n";
return 1;
rval = 1;
}
cout << "IntArray: " << da2 << "\n";
da1 = vtkSmartPointer<vtkDataArray>::NewInstance(ia);
......@@ -72,6 +102,6 @@ int TestSmartPointer(int,char *[])
vtkSmartPointer<vtkIntArray>::Take(vtkIntArray::New());
(void)da4;
ia->Delete();
return 0;
}
return rval;
}
......@@ -23,38 +23,68 @@
int TestWeakPointer(int,char *[])
{
int rval = 0;
vtkIntArray* ia = vtkIntArray::New();
// Coverage:
unsigned int testbits = 0;
unsigned int correctbits = 0x004d3953;
const char *tests[] = {
"da2 == da3", "da2 != da3", "da2 < da3", "da2 <= da3", "da2 > da3",
"da2 >= da3",
"ia == da3", "ia != da3", "ia < da3", "ia <= da3", "ia > da3", "ia >= da3",
"da2 == ia", "da2 != ia", "da2 < ia", "da2 <= ia", "da2 > ia", "da2 <= ia",
"da2 > ia", "da2 >= ia",
"da1 == 0", "da1 != 0", "da1 < 0", "da1 <= 0", "da1 > 0", "da1 >= 0",
NULL };
vtkWeakPointer<vtkIntArray> da2(ia);
vtkWeakPointer<vtkFloatArray> da3;
vtkWeakPointer<vtkDataArray> da1(da2);
da1 = ia;
da1 = da2;
da2 == da3;
da2 != da3;
da2 < da3;
da2 <= da3;
da2 > da3;
da2 >= da3;
ia == da3;
ia != da3;
ia < da3;
ia <= da3;
ia > da3;
ia >= da3;
da2 == ia;
da2 != ia;
da2 < ia;
da2 <= ia;
da2 > ia;
da2 >= ia;
da1 == 0;
da1 != 0;
da1 < 0;
da1 <= 0;
da1 > 0;
da1 >= 0;
testbits = (testbits << 1) | (da2 == da3);
testbits = (testbits << 1) | (da2 != da3);
testbits = (testbits << 1) | (da2 < da3);
testbits = (testbits << 1) | (da2 <= da3);
testbits = (testbits << 1) | (da2 > da3);
testbits = (testbits << 1) | (da2 >= da3);
testbits = (testbits << 1) | (ia == da3);
testbits = (testbits << 1) | (ia != da3);
testbits = (testbits << 1) | (ia < da3);
testbits = (testbits << 1) | (ia <= da3);
testbits = (testbits << 1) | (ia > da3);
testbits = (testbits << 1) | (ia >= da3);
testbits = (testbits << 1) | (da2 == ia);
testbits = (testbits << 1) | (da2 != ia);
testbits = (testbits << 1) | (da2 < ia);
testbits = (testbits << 1) | (da2 <= ia);
testbits = (testbits << 1) | (da2 > ia);
testbits = (testbits << 1) | (da2 >= ia);
testbits = (testbits << 1) | (da1 == 0);
testbits = (testbits << 1) | (da1 != 0);
testbits = (testbits << 1) | (da1 < 0);
testbits = (testbits << 1) | (da1 <= 0);
testbits = (testbits << 1) | (da1 > 0);
testbits = (testbits << 1) | (da1 >= 0);
if (testbits != correctbits)
{
unsigned int diffbits = (testbits ^ correctbits);
int bitcount = 0;
while (tests[bitcount] != NULL)
{
bitcount++;
}
for (int ib = 0; ib < bitcount; ++ib)
{
if (((diffbits >> (bitcount - ib - 1)) & 1) != 0)
{
cerr << "comparison (" << tests[ib] << ") failed!\n";
}
}
rval = 1;
}
(*da1).SetNumberOfComponents(1);
if(da2)
{
......@@ -63,21 +93,24 @@ int TestWeakPointer(int,char *[])
if(!da2)
{
cerr << "da2 is NULL!" << "\n";
return 1;
rval = 1;
}
cout << "IntArray: " << da2 << "\n";
if (da1.GetPointer() == 0)
{
cerr << "da1.GetPointer() is NULL\n";
rval = 1;
}
if (da2.GetPointer() == 0)
{
cerr << "da2.GetPointer() is NULL\n";
rval = 1;
}
if (da3.GetPointer() != 0)
{
cerr << "da3.GetPointer() is not NULL\n";
rval = 1;
}
da2 = 0;
......@@ -86,7 +119,8 @@ int TestWeakPointer(int,char *[])
if (da1.GetPointer() != NULL)
{
cerr << "da1.GetPointer() is not NULL\n";
rval = 1;
}
return 0;
return rval;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment