forked from quic-go/quic-go
Merge pull request #1132 from lucas-clemente/perspective-stringer
add a string representation for the perspective
This commit is contained in:
@@ -8,3 +8,14 @@ const (
|
|||||||
PerspectiveServer Perspective = 1
|
PerspectiveServer Perspective = 1
|
||||||
PerspectiveClient Perspective = 2
|
PerspectiveClient Perspective = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (p Perspective) String() string {
|
||||||
|
switch p {
|
||||||
|
case PerspectiveServer:
|
||||||
|
return "Server"
|
||||||
|
case PerspectiveClient:
|
||||||
|
return "Client"
|
||||||
|
default:
|
||||||
|
return "invalid perspective"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
14
internal/protocol/perspective_test.go
Normal file
14
internal/protocol/perspective_test.go
Normal 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"))
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user