Merge pull request #1132 from lucas-clemente/perspective-stringer

add a string representation for the perspective
This commit is contained in:
Marten Seemann
2018-02-01 23:51:29 +08:00
committed by GitHub
2 changed files with 25 additions and 0 deletions

View File

@@ -8,3 +8,14 @@ const (
PerspectiveServer Perspective = 1
PerspectiveClient Perspective = 2
)
func (p Perspective) String() string {
switch p {
case PerspectiveServer:
return "Server"
case PerspectiveClient:
return "Client"
default:
return "invalid perspective"
}
}

View File

@@ -0,0 +1,14 @@
package protocol
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Perspective", func() {
It("has a string representation", func() {
Expect(PerspectiveClient.String()).To(Equal("Client"))
Expect(PerspectiveServer.String()).To(Equal("Server"))
Expect(Perspective(0).String()).To(Equal("invalid perspective"))
})
})