MCPcopy Create free account
hub / github.com/AdRoll/baker / Test_decompressor_CopyByte

Function Test_decompressor_CopyByte

pkg/buffercache/compressor_test.go:93–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func Test_decompressor_CopyByte(t *testing.T) {
94 tests := []struct {
95 pos int
96 c byte
97 want string
98 }{
99 {
100 pos: 0,
101 c: '*',
102 want: "*\x00\x00\x00",
103 },
104 {
105 pos: 1,
106 c: '*',
107 want: "\x00*\x00\x00",
108 },
109 {
110 pos: 2,
111 c: '*',
112 want: "\x00\x00*\x00",
113 },
114 {
115 pos: 3,
116 c: '*',
117 want: "\x00\x00\x00*",
118 },
119 {
120 pos: 4,
121 c: '*',
122 want: "\x00\x00\x00\x00*",
123 },
124 {
125 pos: 6,
126 c: '*',
127 want: "\x00\x00\x00\x00\x00\x00*",
128 },
129 }
130
131 for _, tt := range tests {
132 d := decompressor{
133 buf: make([]byte, 4),
134 }
135
136 d.copyByte(tt.pos, tt.c)
137
138 if !bytes.Equal(d.buf, []byte(tt.want)) {
139 t.Fatalf("pos=%d b=%c: got %v, want %v", tt.pos, tt.c, d.buf, []byte(tt.want))
140 }
141 }
142}
143
144func Test_compressorBufferGrow(t *testing.T) {
145 // Start with a very small internal buffer to ensure we grow it

Callers

nothing calls this directly

Calls 1

copyByteMethod · 0.95

Tested by

no test coverage detected