test_ctor.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:capnpy 作者: antocuni 项目源码 文件源码
def test_struct(self):
        schema = """
        @0xbf5147cbbecf40c1;
        struct Point {
            x @0 :Int64;
            y @1 :Int64;
        }
        struct Foo {
            x @0 :Point;
        }
        """
        mod = self.compile(schema)
        p = mod.Point(1, 2)
        foo = mod.Foo(p)
        assert foo._seg.buf == b('\x00\x00\x00\x00\x02\x00\x00\x00'  # ptr to point
                                 '\x01\x00\x00\x00\x00\x00\x00\x00'  # p.x == 1
                                 '\x02\x00\x00\x00\x00\x00\x00\x00') # p.y == 2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号