some cleanup and testing
This commit is contained in:
parent
ddcd478567
commit
27b58afe46
2 changed files with 30 additions and 4 deletions
|
@ -1028,8 +1028,6 @@ private:
|
|||
",\n ::capnp::schemas::s_", kj::hex(typeId), ".encodedNode + ", defaultOffset,
|
||||
defaultSize == 0 ? kj::strTree() : kj::strTree(", ", defaultSize));
|
||||
|
||||
kj::String elementReaderType;
|
||||
kj::String elementBuilderType;
|
||||
kj::String builderFactoryArg = kj::str("");
|
||||
kj::String readerFactoryArg = kj::str("");
|
||||
kj::String fieldSize;
|
||||
|
@ -1096,8 +1094,6 @@ private:
|
|||
case schema::Type::LIST:
|
||||
primitiveElement = false;
|
||||
fieldSize = kj::str("org.capnproto.FieldSize.POINTER");
|
||||
elementReaderType = kj::str(typeName(typeBody.getList().getElementType()), ".Reader");
|
||||
elementBuilderType = kj::str(typeName(typeBody.getList().getElementType()), ".Builder");
|
||||
readerFactoryArg = kj::str(makeListListFactoryArg(typeBody.getList().getElementType()), ", ");
|
||||
builderFactoryArg = kj::str(readerFactoryArg);
|
||||
break;
|
||||
|
|
|
@ -68,6 +68,36 @@ class EncodingSuite extends FunSuite {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
test("NestedLists") {
|
||||
val builder = new MessageBuilder();
|
||||
val root = builder.initRoot(TestLists.factory);
|
||||
{
|
||||
val intListList = root.initInt32ListList(2);
|
||||
val intList0 = intListList.init(0, 4);
|
||||
intList0.set(0, 1);
|
||||
intList0.set(1, 2);
|
||||
intList0.set(2, 3);
|
||||
intList0.set(3, 4);
|
||||
val intList1 = intListList.init(1, 1);
|
||||
intList1.set(0, 100);
|
||||
}
|
||||
{
|
||||
val reader = root.asReader();
|
||||
val intListList = root.getInt32ListList();
|
||||
intListList.size() should equal (2);
|
||||
val intList0 = intListList.get(0);
|
||||
intList0.size() should equal (4);
|
||||
intList0.get(0) should equal (1);
|
||||
intList0.get(1) should equal (2);
|
||||
intList0.get(2) should equal (3);
|
||||
intList0.get(3) should equal (4);
|
||||
val intList1 = intListList.get(1);
|
||||
intList1.size() should equal (1);
|
||||
intList1.get(0) should equal(100);
|
||||
}
|
||||
}
|
||||
|
||||
test("UpgradeStructInBuilder") {
|
||||
val builder = new MessageBuilder();
|
||||
val root = builder.initRoot(TestAnyPointer.factory);
|
||||
|
|
Loading…
Reference in a new issue