aboutsummaryrefslogtreecommitdiff
path: root/examples/list_people_test.go
diff options
context:
space:
mode:
authorFeng Xiao <xiaofeng@google.com>2015-12-17 11:42:59 -0800
committerFeng Xiao <xiaofeng@google.com>2015-12-17 11:42:59 -0800
commit9e1777f4b05da6a65e2a60680e5924a802ae5c94 (patch)
tree752ad968c2c9074b5d5fbd7802a089132094e7fa /examples/list_people_test.go
parentafbc89a263d57bb2e36ce5f07b979c739bb2e8cd (diff)
parent7df1d773b7752fc51460fa0f116ed5a74d9d514b (diff)
downloadprotobuf-9e1777f4b05da6a65e2a60680e5924a802ae5c94.tar.gz
protobuf-9e1777f4b05da6a65e2a60680e5924a802ae5c94.tar.bz2
protobuf-9e1777f4b05da6a65e2a60680e5924a802ae5c94.zip
Merge pull request #1052 from tswast/master
Add region tags to the Go protobuf examples.
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{