(c *C)
| 113 | } |
| 114 | |
| 115 | func (s *SuiteEncoder) TestEncodeStrings(c *C) { |
| 116 | for i, test := range [...]struct { |
| 117 | input []string |
| 118 | expected []byte |
| 119 | }{ |
| 120 | { |
| 121 | input: []string{ |
| 122 | "hello\n", |
| 123 | }, |
| 124 | expected: []byte("000ahello\n"), |
| 125 | }, { |
| 126 | input: []string{ |
| 127 | "hello\n", |
| 128 | pktline.FlushString, |
| 129 | }, |
| 130 | expected: []byte("000ahello\n0000"), |
| 131 | }, { |
| 132 | input: []string{ |
| 133 | "hello\n", |
| 134 | "world!\n", |
| 135 | "foo", |
| 136 | }, |
| 137 | expected: []byte("000ahello\n000bworld!\n0007foo"), |
| 138 | }, { |
| 139 | input: []string{ |
| 140 | "hello\n", |
| 141 | pktline.FlushString, |
| 142 | "world!\n", |
| 143 | "foo", |
| 144 | pktline.FlushString, |
| 145 | }, |
| 146 | expected: []byte("000ahello\n0000000bworld!\n0007foo0000"), |
| 147 | }, { |
| 148 | input: []string{ |
| 149 | strings.Repeat("a", pktline.MaxPayloadSize), |
| 150 | }, |
| 151 | expected: []byte( |
| 152 | "fff0" + strings.Repeat("a", pktline.MaxPayloadSize)), |
| 153 | }, { |
| 154 | input: []string{ |
| 155 | strings.Repeat("a", pktline.MaxPayloadSize), |
| 156 | strings.Repeat("b", pktline.MaxPayloadSize), |
| 157 | }, |
| 158 | expected: []byte( |
| 159 | "fff0" + strings.Repeat("a", pktline.MaxPayloadSize) + |
| 160 | "fff0" + strings.Repeat("b", pktline.MaxPayloadSize)), |
| 161 | }, |
| 162 | } { |
| 163 | comment := Commentf("input %d = %v\n", i, test.input) |
| 164 | |
| 165 | var buf bytes.Buffer |
| 166 | e := pktline.NewEncoder(&buf) |
| 167 | |
| 168 | err := e.EncodeString(test.input...) |
| 169 | c.Assert(err, IsNil, comment) |
| 170 | c.Assert(buf.Bytes(), DeepEquals, test.expected, comment) |
| 171 | } |
| 172 | } |
nothing calls this directly
no test coverage detected