github.com/apernet/quic-go@v0.43.1-0.20240515053213-5e9e635fd9f0/internal/protocol/key_phase_test.go (about)

     1  package protocol
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo/v2"
     5  	. "github.com/onsi/gomega"
     6  )
     7  
     8  var _ = Describe("Key Phases", func() {
     9  	It("has undefined as its default value", func() {
    10  		var k KeyPhaseBit
    11  		Expect(k).To(Equal(KeyPhaseUndefined))
    12  	})
    13  
    14  	It("has the correct string representation", func() {
    15  		Expect(KeyPhaseZero.String()).To(Equal("0"))
    16  		Expect(KeyPhaseOne.String()).To(Equal("1"))
    17  	})
    18  
    19  	It("converts the key phase to the key phase bit", func() {
    20  		Expect(KeyPhase(0).Bit()).To(Equal(KeyPhaseZero))
    21  		Expect(KeyPhase(2).Bit()).To(Equal(KeyPhaseZero))
    22  		Expect(KeyPhase(4).Bit()).To(Equal(KeyPhaseZero))
    23  		Expect(KeyPhase(1).Bit()).To(Equal(KeyPhaseOne))
    24  		Expect(KeyPhase(3).Bit()).To(Equal(KeyPhaseOne))
    25  		Expect(KeyPhase(5).Bit()).To(Equal(KeyPhaseOne))
    26  	})
    27  })