diff options
author | Jakob Buchgraber <buchgr@google.com> | 2017-04-26 15:37:42 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-05-02 09:51:34 +0200 |
commit | 2b49f678a7dfaf27afc0e44ed7a65b00ec06d413 (patch) | |
tree | c1c46d0f1f66859ff42fd41f0aefb6436c9f4507 /third_party/protobuf/3.2.0/examples/add_person_test.go | |
parent | b712f335a945c81a6b77fd48e96103ff09c8967b (diff) |
Update third_party/protobuf to pre-release 3.2.0
Update protobuf to @laszlocsomor's fork of protobuf. This is essentially
the development version of protobuf 3.2.0 and windows specific fixes
from laszlo. Those fixes will be merged into protobuf soon:
https://github.com/google/protobuf/pull/2969.
Change-Id: Id88cd7e5b2c27ab74f3ecfa1e127e5a863f2deb3
Diffstat (limited to 'third_party/protobuf/3.2.0/examples/add_person_test.go')
-rw-r--r-- | third_party/protobuf/3.2.0/examples/add_person_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/third_party/protobuf/3.2.0/examples/add_person_test.go b/third_party/protobuf/3.2.0/examples/add_person_test.go new file mode 100644 index 0000000000..0507db6fc1 --- /dev/null +++ b/third_party/protobuf/3.2.0/examples/add_person_test.go @@ -0,0 +1,58 @@ +package main + +import ( + "strings" + "testing" + + "github.com/golang/protobuf/proto" + pb "github.com/google/protobuf/examples/tutorial" +) + +func TestPromptForAddressReturnsAddress(t *testing.T) { + in := `12345 +Example Name +name@example.com +123-456-7890 +home +222-222-2222 +mobile +111-111-1111 +work +777-777-7777 +unknown + +` + got, err := promptForAddress(strings.NewReader(in)) + if err != nil { + t.Fatalf("promptForAddress(%q) had unexpected error: %s", in, err.Error()) + } + if got.Id != 12345 { + t.Errorf("promptForAddress(%q) got %d, want ID %d", in, got.Id, 12345) + } + if got.Name != "Example Name" { + t.Errorf("promptForAddress(%q) => want name %q, got %q", "Example Name", got.Name) + } + if got.Email != "name@example.com" { + t.Errorf("promptForAddress(%q) => want email %q, got %q", "name@example.com", got.Email) + } + + want := []*pb.Person_PhoneNumber{ + {Number: "123-456-7890", Type: pb.Person_HOME}, + {Number: "222-222-2222", Type: pb.Person_MOBILE}, + {Number: "111-111-1111", Type: pb.Person_WORK}, + {Number: "777-777-7777", Type: pb.Person_MOBILE}, + } + if len(got.Phones) != len(want) { + t.Errorf("want %d phone numbers, got %d", len(want), len(got.Phones)) + } + phones := len(got.Phones) + if phones > len(want) { + phones = len(want) + } + for i := 0; i < phones; i++ { + if !proto.Equal(got.Phones[i], want[i]) { + t.Errorf("want phone %q, got %q", *want[i], *got.Phones[i]) + } + + } +} |