2011-07-27 19:07:14 +08:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2011-10-03 15:40:27 +08:00
|
|
|
import unittest
|
|
|
|
import target
|
|
|
|
import pykd
|
2011-07-27 19:07:14 +08:00
|
|
|
|
2011-10-03 15:40:27 +08:00
|
|
|
class TypeInfoTest( unittest.TestCase ):
|
2011-07-27 19:07:14 +08:00
|
|
|
|
2011-10-03 15:40:27 +08:00
|
|
|
def testCtor( self ):
|
|
|
|
""" typeInfo class can not be created direct """
|
|
|
|
try: pykd.typeInfo()
|
|
|
|
except RuntimeError: pass
|
|
|
|
|
|
|
|
def testCreateByName( self ):
|
|
|
|
""" creating typeInfo by the type name """
|
|
|
|
ti1 = target.module.type( "structTest" )
|
|
|
|
ti2 = target.module.type( "classChild" )
|
2011-10-04 15:00:54 +08:00
|
|
|
|
|
|
|
def testGetField( self ):
|
|
|
|
""" get field of the complex type """
|
|
|
|
ti1 = target.module.type( "structTest" )
|
2011-10-06 14:26:25 +08:00
|
|
|
self.assertTrue( hasattr( ti1, "m_field0" ) )
|
|
|
|
try: hasattr(ti1, "m_field4" ) # non-exsisting field
|
2011-10-04 15:00:54 +08:00
|
|
|
except pykd.DiaException: pass
|
|
|
|
|
|
|
|
def testName( self ):
|
|
|
|
ti1 = target.module.type( "classChild" )
|
|
|
|
self.assertEqual( "classChild", ti1.name() )
|
|
|
|
self.assertEqual( "Int", ti1.m_childField.name() )
|
|
|
|
self.assertEqual( "structTest", ti1.m_childField3.name() )
|
|
|
|
|
|
|
|
def testOffset( self ):
|
|
|
|
ti1 = target.module.type( "structTest" )
|
|
|
|
self.assertEqual( 0, ti1.m_field0.offset() )
|
|
|
|
self.assertEqual( 4, ti1.m_field1.offset() )
|
|
|
|
self.assertEqual( 12, ti1.m_field2.offset() )
|
2011-10-06 14:26:25 +08:00
|
|
|
self.assertEqual( 14, ti1.m_field3.offset() )
|
|
|
|
|
|
|
|
def testSize( self ):
|
|
|
|
ti1 = target.module.type( "structTest" )
|
|
|
|
self.assertEqual( 16, ti1.size() )
|
2011-10-04 15:00:54 +08:00
|
|
|
|