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

Method testSparseArray

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

Test vtkSparseArray template

(self)

Source from the content-addressed store, hash-verified

83 self.assertEqual(value, result)
84
85 def testSparseArray(self):
86 """Test vtkSparseArray template"""
87 for t in (arrayTypes + arrayCodes):
88 a = vtkSparseArray[t]()
89 a.Resize(1)
90 i = vtkArrayCoordinates(0)
91 if t in ['bool', '?']:
92 value = 0
93 a.SetValue(i, value)
94 result = a.GetValue(i)
95 self.assertEqual(value, result)
96 elif t in ['float32', 'float64', 'float', 'f', 'd']:
97 value = 3.125
98 a.SetValue(i, value)
99 result = a.GetValue(i)
100 self.assertEqual(value, result)
101 elif t in ['char', 'c']:
102 value = 'c'
103 a.SetValue(i, value)
104 result = a.GetValue(i)
105 self.assertEqual(value, result)
106 elif t in [str, 'str']:
107 value = "hello"
108 a.SetValue(i, value)
109 result = a.GetValue(i)
110 self.assertEqual(value, result)
111 value = francois
112 a.SetValue(i, value)
113 result = a.GetValue(i)
114 self.assertEqual(value, result)
115 elif t in ['vtkVariant', vtkVariant]:
116 value = vtkVariant("world")
117 a.SetValue(i, value)
118 result = a.GetValue(i)
119 self.assertEqual(value, result)
120 else:
121 value = 12
122 a.SetValue(i, value)
123 result = a.GetValue(i)
124 self.assertEqual(value, result)
125
126 def testArray(self):
127 """Test array CreateArray"""

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