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

Method testTwoArgConstructor

Common/Core/Testing/Python/TestVariant.py:94–111  ·  view source on GitHub ↗

Construct with a specific type

(self)

Source from the content-addressed store, hash-verified

92 self.assertEqual(v.ToVTKObject(), o)
93
94 def testTwoArgConstructor(self):
95 """Construct with a specific type"""
96 # construct with conversion to int
97 v = vtkVariant('10')
98 u = vtkVariant(v, VTK_INT)
99 self.assertEqual(u.GetType(), VTK_INT)
100 self.assertEqual(v.ToInt(), u.ToInt())
101
102 # construct with conversion to double
103 v = vtkVariant(10)
104 u = vtkVariant(v, VTK_DOUBLE)
105 self.assertEqual(u.GetType(), VTK_DOUBLE)
106 self.assertEqual(u.ToDouble(), 10.0)
107
108 # failed conversion to vtkObject
109 v = vtkVariant(10)
110 u = vtkVariant(v, VTK_OBJECT)
111 self.assertEqual(u.IsValid(), False)
112
113 def testAutomaticArgConversion(self):
114 """Automatic construction of variants to resolve args"""

Callers

nothing calls this directly

Calls 5

vtkVariantClass · 0.50
GetTypeMethod · 0.45
ToIntMethod · 0.45
ToDoubleMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected