muxwriter_test.go 594 B

123456789101112131415161718192021222324252627
  1. package h2mux
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestChopEncodedHeaders(t *testing.T) {
  7. mockEncodedHeaders := make([]byte, 5)
  8. for i := range mockEncodedHeaders {
  9. mockEncodedHeaders[i] = byte(i)
  10. }
  11. chopped := chopEncodedHeaders(mockEncodedHeaders, 4)
  12. assert.Equal(t, 2, len(chopped))
  13. assert.Equal(t, []byte{0, 1, 2, 3}, chopped[0])
  14. assert.Equal(t, []byte{4}, chopped[1])
  15. }
  16. func TestChopEncodedEmptyHeaders(t *testing.T) {
  17. mockEncodedHeaders := make([]byte, 0)
  18. chopped := chopEncodedHeaders(mockEncodedHeaders, 3)
  19. assert.Equal(t, 0, len(chopped))
  20. }