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

Method testCharArray

Common/Core/Testing/Python/TestBuffer.py:85–99  ·  view source on GitHub ↗

Test the special case of the char array.

(self)

Source from the content-addressed store, hash-verified

83 self.assertEqual(tp, (10, 7, 4, 85, 8, 2))
84
85 def testCharArray(self):
86 """Test the special case of the char array."""
87 # bit array is actually stored as a byte array
88 a = vtkCharArray()
89 a.SetNumberOfComponents(5)
90 a.InsertNextTypedTuple("hello")
91 a.InsertNextTypedTuple("world")
92 m = memoryview(a)
93 self.assertEqual(m.format, 'c')
94 self.assertEqual(m.itemsize, 1)
95 self.assertEqual(m.shape, (2, 5))
96 self.assertEqual(m.strides, (5, 1))
97 self.assertEqual(m.ndim, 2)
98 # test the contents of the memoryview
99 self.assertEqual(m.tobytes(), b"helloworld")
100
101 def testBitArray(self):
102 """Test the special case of the bit array."""

Callers

nothing calls this directly

Calls 2

vtkCharArrayFunction · 0.50
SetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected