test_ctor.py 文件源码

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

项目:capnpy 作者: antocuni 项目源码 文件源码
def test_list_of_text(self):
        schema = """
        @0xbf5147cbbecf40c1;
        struct Foo {
            x @0 :List(Text);
        }
        """
        mod = self.compile(schema)
        foo = mod.Foo([b'foo', b'bar', b'baz'])
        expected = b('\x01\x00\x00\x00\x1e\x00\x00\x00'    # ptrlist
                     '\x09\x00\x00\x00\x22\x00\x00\x00'
                     '\x09\x00\x00\x00\x22\x00\x00\x00'
                     '\x09\x00\x00\x00\x22\x00\x00\x00'
                     'foo\x00\x00\x00\x00\x00'
                     'bar\x00\x00\x00\x00\x00'
                     'baz\x00\x00\x00\x00\x00')
        assert foo._seg.buf == expected
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号