From 4380d283f47428a0670fa9c88d32348d0598b9e1 Mon Sep 17 00:00:00 2001 From: Alex Helfet Date: Sun, 2 Apr 2017 23:59:05 +0100 Subject: [PATCH] Add URL for original addressbook example; example to assert list length with capn_len(). --- tests/addressbook.capnp | 3 ++- tests/example-test.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/addressbook.capnp b/tests/addressbook.capnp index faedaa0..c2b85f4 100644 --- a/tests/addressbook.capnp +++ b/tests/addressbook.capnp @@ -1,4 +1,5 @@ -# From https://github.com/sandstorm-io/capnproto/blob/6816634a08b08bc8f52b4ee809afb58389f19655/c%2B%2B/samples/addressbook.capnp +# Based on the addressbook.capnp example in the capnproto C++ project: +# https://github.com/sandstorm-io/capnproto/blob/6816634a08b08bc8f52b4ee809afb58389f19655/c%2B%2B/samples/addressbook.capnp # # Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors # Licensed under the MIT License: diff --git a/tests/example-test.cpp b/tests/example-test.cpp index e16855a..10f0ff8 100644 --- a/tests/example-test.cpp +++ b/tests/example-test.cpp @@ -1,6 +1,9 @@ /* example-test.cpp * - * Some simple examples using c-capnproto + * Some simple examples using c-capnproto. + * + * Based on the addressbook.capnp example in the capnproto C++ project: + * https://github.com/sandstorm-io/capnproto/blob/6816634a08b08bc8f52b4ee809afb58389f19655/c%2B%2B/samples/addressbook.capnp * * Copyright (C) 2017 Alex Helfet * @@ -107,6 +110,8 @@ TEST(Examples, RoundTripPerson) { EXPECT_EQ(rp.employment_which, Person_employment_school); EXPECT_CAPN_TEXT_EQ(school, rp.employment.school); + EXPECT_EQ(2, capn_len(rp.phones)); + struct Person_PhoneNumber rpn0; get_Person_PhoneNumber(&rpn0, rp.phones, 0); EXPECT_CAPN_TEXT_EQ("123", rpn0.number);