test_ctor.py 文件源码

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

项目:capnpy 作者: antocuni 项目源码 文件源码
def test_list_of_lists(self):
        schema = """
        @0xbf5147cbbecf40c1;
        struct Foo {
            x @0 :List(List(Int8));
        }
        """
        mod = self.compile(schema)
        foo = mod.Foo([[1, 2, 3], [4, 5], [6, 7, 8, 9]])
        expected = b('\x01\x00\x00\x00\x1e\x00\x00\x00'  # list<ptr> (3 items)
                     '\x09\x00\x00\x00\x1a\x00\x00\x00'  # list<8> (3 items)
                     '\x09\x00\x00\x00\x12\x00\x00\x00'  # list<8> (2 items)
                     '\x09\x00\x00\x00\x22\x00\x00\x00'  # list<8> (4 items)
                     '\x01\x02\x03\x00\x00\x00\x00\x00'
                     '\x04\x05\x00\x00\x00\x00\x00\x00'
                     '\x06\x07\x08\x09\x00\x00\x00\x00')
        assert foo._seg.buf == expected
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号