aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/list_people_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'examples/list_people_test.go')
-rw-r--r--examples/list_people_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/list_people_test.go b/examples/list_people_test.go
index 721d3555..87d6ad6e 100644
--- a/examples/list_people_test.go
+++ b/examples/list_people_test.go
@@ -8,6 +8,30 @@ import (
pb "github.com/google/protobuf/examples/tutorial"
)
+func TestWritePersonWritesPerson(t *testing.T) {
+ buf := new(bytes.Buffer)
+ // [START populate_proto]
+ p := pb.Person{
+ Id: 1234,
+ Name: "John Doe",
+ Email: "jdoe@example.com",
+ Phones: []*pb.Person_PhoneNumber{
+ {Number: "555-4321", Type: pb.Person_HOME},
+ },
+ }
+ // [END populate_proto]
+ writePerson(buf, &p)
+ got := buf.String()
+ want := `Person ID: 1234
+ Name: John Doe
+ E-mail address: jdoe@example.com
+ Home phone #: 555-4321
+`
+ if got != want {
+ t.Errorf("writePerson(%s) =>\n\t%q, want %q", p.String(), got, want)
+ }
+}
+
func TestListPeopleWritesList(t *testing.T) {
buf := new(bytes.Buffer)
in := pb.AddressBook{[]*pb.Person{