aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTim Swast <swast@google.com>2015-12-16 14:46:28 -0800
committerTim Swast <swast@google.com>2015-12-16 14:46:28 -0800
commit7df1d773b7752fc51460fa0f116ed5a74d9d514b (patch)
treef33d1eb3551506cc2d2886ddc7a0f2358b187c9b /examples
parent1cc541b3be263d92aba435b183aca5ad7151ae8a (diff)
downloadprotobuf-7df1d773b7752fc51460fa0f116ed5a74d9d514b.tar.gz
protobuf-7df1d773b7752fc51460fa0f116ed5a74d9d514b.tar.bz2
protobuf-7df1d773b7752fc51460fa0f116ed5a74d9d514b.zip
Improves readability of Go example test.
Diffstat (limited to 'examples')
-rw-r--r--examples/list_people_test.go30
1 files changed, 5 insertions, 25 deletions
diff --git a/examples/list_people_test.go b/examples/list_people_test.go
index d995aa1c..87d6ad6e 100644
--- a/examples/list_people_test.go
+++ b/examples/list_people_test.go
@@ -21,34 +21,14 @@ func TestWritePersonWritesPerson(t *testing.T) {
}
// [END populate_proto]
writePerson(buf, &p)
- want := strings.Split(`Person ID: 1234
+ got := buf.String()
+ want := `Person ID: 1234
Name: John Doe
E-mail address: jdoe@example.com
Home phone #: 555-4321
-`, "\n")
-
- got := strings.Split(buf.String(), "\n")
- if len(got) != len(want) {
- t.Errorf(
- "writePerson(%s) =>\n\t%q has %d lines, want %d",
- p.String(),
- buf.String(),
- len(got),
- len(want))
- }
- lines := len(got)
- if lines > len(want) {
- lines = len(want)
- }
- for i := 0; i < lines; i++ {
- if got[i] != want[i] {
- t.Errorf(
- "writePerson(%s) =>\n\tline %d %q, want %q",
- p.String(),
- i,
- got[i],
- want[i])
- }
+`
+ if got != want {
+ t.Errorf("writePerson(%s) =>\n\t%q, want %q", p.String(), got, want)
}
}