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

Method testDenseArray

Common/DataModel/Testing/Python/TestTemplates.py:44–83  ·  view source on GitHub ↗

Test vtkDenseArray template

(self)

Source from the content-addressed store, hash-verified

42class TestTemplates(Testing.vtkTest):
43
44 def testDenseArray(self):
45 """Test vtkDenseArray template"""
46 for t in (arrayTypes + arrayCodes):
47 a = vtkDenseArray[t]()
48 a.Resize(1)
49 i = vtkArrayCoordinates(0)
50 if t in ['bool', '?']:
51 value = 1
52 a.SetValue(i, value)
53 result = a.GetValue(i)
54 self.assertEqual(value, result)
55 elif t in ['float32', 'float64', 'float', 'f', 'd']:
56 value = 3.125
57 a.SetValue(i, value)
58 result = a.GetValue(i)
59 self.assertEqual(value, result)
60 elif t in ['char', 'c']:
61 value = 'c'
62 a.SetValue(i, value)
63 result = a.GetValue(i)
64 self.assertEqual(value, result)
65 elif t in [str, 'str']:
66 value = "hello"
67 a.SetValue(i, value)
68 result = a.GetValue(i)
69 self.assertEqual(value, result)
70 value = francois
71 a.SetValue(i, value)
72 result = a.GetValue(i)
73 self.assertEqual(value, result)
74 elif t in ['vtkVariant', vtkVariant]:
75 value = vtkVariant("world")
76 a.SetValue(i, value)
77 result = a.GetValue(i)
78 self.assertEqual(value, result)
79 else:
80 value = 12
81 a.SetValue(i, value)
82 result = a.GetValue(i)
83 self.assertEqual(value, result)
84
85 def testSparseArray(self):
86 """Test vtkSparseArray template"""

Callers

nothing calls this directly

Calls 4

vtkVariantClass · 0.50
ResizeMethod · 0.45
SetValueMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected