MCPcopy Create free account
hub / github.com/Kitware/VTK / TestArrayAPI

Function TestArrayAPI

Common/Core/Testing/Cxx/TestArrayAPI.cxx:24–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 } while (false)
23
24int TestArrayAPI(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
25{
26 try
27 {
28 vtkSmartPointer<vtkArray> array;
29
30 // Test to see that we can create every supported combination of storage- and value-type.
31 std::vector<int> storage_types;
32 storage_types.push_back(vtkArray::DENSE);
33 storage_types.push_back(vtkArray::SPARSE);
34
35 std::vector<int> value_types;
36 value_types.push_back(VTK_CHAR);
37 value_types.push_back(VTK_UNSIGNED_CHAR);
38 value_types.push_back(VTK_SHORT);
39 value_types.push_back(VTK_UNSIGNED_SHORT);
40 value_types.push_back(VTK_INT);
41 value_types.push_back(VTK_UNSIGNED_INT);
42 value_types.push_back(VTK_LONG);
43 value_types.push_back(VTK_UNSIGNED_LONG);
44 value_types.push_back(VTK_DOUBLE);
45 value_types.push_back(VTK_ID_TYPE);
46 value_types.push_back(VTK_STRING);
47 value_types.push_back(VTK_VARIANT);
48
49 std::vector<vtkVariant> sample_values;
50 sample_values.emplace_back(static_cast<char>(1));
51 sample_values.emplace_back(static_cast<unsigned char>(2));
52 sample_values.emplace_back(static_cast<short>(3));
53 sample_values.emplace_back(static_cast<unsigned short>(4));
54 sample_values.emplace_back(5);
55 sample_values.emplace_back(static_cast<unsigned int>(6));
56 sample_values.emplace_back(static_cast<long>(7));
57 sample_values.emplace_back(static_cast<unsigned long>(8));
58 sample_values.emplace_back(9.0);
59 sample_values.emplace_back(static_cast<vtkIdType>(10));
60 sample_values.emplace_back(vtkStdString("11"));
61 sample_values.emplace_back(12.0f);
62
63 for (std::vector<int>::const_iterator storage_type = storage_types.begin();
64 storage_type != storage_types.end(); ++storage_type)
65 {
66 for (size_t value_type = 0; value_type != value_types.size(); ++value_type)
67 {
68 std::cerr << "creating array with storage type " << *storage_type << " and value type "
69 << vtkImageScalarTypeNameMacro(value_types[value_type]) << std::endl;
70
71 array.TakeReference(vtkArray::CreateArray(*storage_type, value_types[value_type]));
72 test_expression(array);
73
74 test_expression(array->GetName().empty());
75 array->SetName("foo");
76 test_expression(array->GetName() == "foo");
77
78 array->Resize(10);
79 array->SetVariantValue(5, sample_values[value_type]);
80 test_expression(array->GetVariantValue(5).IsValid());
81 test_expression(array->GetVariantValue(5) == sample_values[value_type]);

Callers

nothing calls this directly

Calls 15

test_expressionFunction · 0.85
CreateArrayFunction · 0.70
vtkStdStringClass · 0.50
push_backMethod · 0.45
emplace_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
TakeReferenceMethod · 0.45
emptyMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected