Add init method to lists

This commit is contained in:
Jason Paryani
2015-05-04 11:00:25 -07:00
parent 3d77722e88
commit a5bf532d53
4 changed files with 29 additions and 0 deletions

View File

@@ -37,3 +37,6 @@ struct AddressBook {
people @0 :List(Person);
}
struct NestedList {
list @0 :List(List(Int32));
}

View File

@@ -218,3 +218,16 @@ def test_to_dict_ordered(addressbook):
else:
with pytest.raises(Exception):
person.to_dict(ordered=True)
def test_nested_list(addressbook):
struct = addressbook.NestedList.new_message()
struct.init('list', 2)
struct.list.init(0, 1)
struct.list.init(1, 2)
struct.list[0][0] = 1
struct.list[1][0] = 2
struct.list[1][1] = 3
assert struct.to_dict()["list"] == [[1], [2,3]]