# Path: zoonado/protocol/primitives.py
# class Primitive(object):
# class VariablePrimitive(Primitive):
# class Bool(Primitive):
# class Byte(Primitive):
# class Int(Primitive):
# class Long(Primitive):
# class Float(Primitive):
# class Double(Primitive):
# class UString(VariablePrimitive):
# class Buffer(VariablePrimitive):
# class Vector(Primitive):
#     def __init__(self, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __eq__(self, other):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def of(cls, part_class):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __str__(self):
# 
# Path: zoonado/protocol/part.py
# class Part(object):
#     def __init__(self, **kwargs):
#     def render(self, parts=None):
#     def parse(cls, buff, offset):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __str__(self):
#         def subpart_string(part_info):


import struct
import unittest
from zoonado.protocol import primitives, part
    def test_buffer_parsing(self):
        raw = struct.pack("!i3s", 3, b"fo\xc3")

        value, new_offset = primitives.Buffer.parse(raw, offset=0)

        self.assertEqual(value, b"fo\xc3")
        self.assertEqual(new_offset, 7)

    def test_ustring_string(self):
        s = primitives.UString(u"foobar")

        self.assertEqual(str(s), str(u"foobar"))

    def test_vector_string(self):
        a = primitives.Vector.of(primitives.Int)([1, 3, 6, 9])

        self.assertEqual(str(a), "Int[1, 3, 6, 9]")

    def test_ustring_render_parse_is_stable(self):
        s = primitives.UString(u"foobar")

        fmt, values = s.render()

        raw = struct.pack("!" + fmt, *values)

        value, _ = primitives.UString.parse(raw, 0)

        self.assertEqual(value, u"foobar")

    def test_ustring_render_parse_handles_strings(self):

# Path: zoonado/protocol/primitives.py
# class Primitive(object):
# class VariablePrimitive(Primitive):
# class Bool(Primitive):
# class Byte(Primitive):
# class Int(Primitive):
# class Long(Primitive):
# class Float(Primitive):
# class Double(Primitive):
# class UString(VariablePrimitive):
# class Buffer(VariablePrimitive):
# class Vector(Primitive):
#     def __init__(self, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __eq__(self, other):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def of(cls, part_class):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __str__(self):
# 
# Path: zoonado/protocol/part.py
# class Part(object):
#     def __init__(self, **kwargs):
#     def render(self, parts=None):
#     def parse(cls, buff, offset):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __str__(self):
#         def subpart_string(part_info):


# Path: tests/protocol/test_primitives.py
import struct
import unittest
from zoonado.protocol import primitives, part

    def test_buffer_parsing(self):
        raw = struct.pack("!i3s", 3, b"fo\xc3")

        value, new_offset = primitives.Buffer.parse(raw, offset=0)

        self.assertEqual(value, b"fo\xc3")
        self.assertEqual(new_offset, 7)

    def test_ustring_string(self):
        s = primitives.UString(u"foobar")

        self.assertEqual(str(s), str(u"foobar"))

    def test_vector_string(self):
        a = primitives.Vector.of(primitives.Int)([1, 3, 6, 9])

        self.assertEqual(str(a), "Int[1, 3, 6, 9]")

    def test_ustring_render_parse_is_stable(self):
        s = primitives.UString(u"foobar")

        fmt, values = s.render()

        raw = struct.pack("!" + fmt, *values)

        value, _ = primitives.UString.parse(raw, 0)

        self.assertEqual(value, u"foobar")

    def test_ustring_render_parse_handles_strings(self):

        s = primitives.UString("bazzzz")