def test_complex(self): t = complex_type('double _Complex', 16, float_type('double', 8)) self.assertEqual(t.kind, TypeKind.COMPLEX) self.assertIsNone(t.primitive) self.assertEqual(t.name, 'double _Complex') self.assertEqual(t.size, 16) self.assertEqual(t.type, float_type('double', 8)) self.assertTrue(t.is_complete()) self.assertEqual( t, complex_type('double _Complex', 16, float_type('double', 8))) self.assertNotEqual( t, complex_type('float _Complex', 16, float_type('double', 8))) self.assertNotEqual( t, complex_type('double _Complex', 32, float_type('double', 8))) self.assertNotEqual( t, complex_type('double _Complex', 16, float_type('float', 4))) self.assertEqual( repr(t), "complex_type(name='double _Complex', size=16, type=float_type(name='double', size=8))" ) self.assertRaises(TypeError, complex_type, None, 16, float_type('double', 8)) self.assertRaises(TypeError, complex_type, 'double _Complex', 16, None) self.assertRaisesRegex(ValueError, 'must be floating-point or integer type', complex_type, 'double _Complex', 16, void_type()) self.assertRaisesRegex(ValueError, 'must be unqualified', complex_type, 'double _Complex', 16, float_type('double', 8, Qualifiers.CONST))
def test_complex(self): t = complex_type("double _Complex", 16, float_type("double", 8)) self.assertEqual(t.kind, TypeKind.COMPLEX) self.assertIsNone(t.primitive) self.assertEqual(t.language, DEFAULT_LANGUAGE) self.assertEqual(t.name, "double _Complex") self.assertEqual(t.size, 16) self.assertEqual(t.type, float_type("double", 8)) self.assertTrue(t.is_complete()) self.assertEqual( t, complex_type("double _Complex", 16, float_type("double", 8))) self.assertNotEqual( t, complex_type("float _Complex", 16, float_type("double", 8))) self.assertNotEqual( t, complex_type("double _Complex", 32, float_type("double", 8))) self.assertNotEqual( t, complex_type("double _Complex", 16, float_type("float", 4))) self.assertEqual( repr(t), "complex_type(name='double _Complex', size=16, type=float_type(name='double', size=8))", ) self.assertEqual(sizeof(t), 16) self.assertRaises(TypeError, complex_type, None, 16, float_type("double", 8)) self.assertRaises(TypeError, complex_type, "double _Complex", 16, None) self.assertRaisesRegex( ValueError, "must be floating-point or integer type", complex_type, "double _Complex", 16, void_type(), ) self.assertRaisesRegex( ValueError, "must be unqualified", complex_type, "double _Complex", 16, float_type("double", 8, Qualifiers.CONST), )