Overview
Comment: | Fixed Decode's length return and added a test for it. Reduce encoder's buffer to 2 bytes. CC at 98.3% |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ea97951fcdfd21a1a3c66adbefb8253c |
User & Date: | spaskalev on 2015-01-01 06:34:04 |
Other Links: | manifest | tags |
Context
2015-01-01
| ||
14:11 | Initial implementation and test of fibonacci.Reader(io.Reader) io.Reader that decodes bytes encoded from fibonacci.Writer(..). CC at 97.5% check-in: 4b9f9bff39 user: spaskalev tags: trunk | |
06:34 | Fixed Decode's length return and added a test for it. Reduce encoder's buffer to 2 bytes. CC at 98.3% check-in: ea97951fcd user: spaskalev tags: trunk | |
05:30 | Added a proper test for fibonacci.Writer that writes 0-255, converts the resulting bits to a string and compares against the result of Numbers.Code for each value. check-in: c7c8d6445f user: spaskalev tags: trunk | |
Changes
Modified src/0dev.org/encoding/fibonacci/fib.go from [2d2f3f4577] to [bc261fa076].
︙ | |||
69 70 71 72 73 74 75 | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | - + - - + - + | length += 2 continue } value >>= 1 length++ } |
︙ | |||
173 174 175 176 177 178 179 | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | // Numbers // source io.Reader // buffer uint64 // at byte // } // func (d *decoder) Read(output []byte) (int, error) { // var ( // total int // err error // ) // // While we have suitable buffered data and enough output space // for (len(output) > 0) && ((d.buffer & (d.buffer >> 1)) > 0) { // val, len := d.Decode(d.buffer) // // Store the decoded byte // output[0] = byte(val) // // Advance the internal and output buffers // output = output[1:] // d.buffer >>= len // // TODO - decrease d.at as well ? // total++ // } // // Termination condition // if len(output) == 0 { // return total, nil // } // // count, err := d.source.Read(output) |
Modified src/0dev.org/encoding/fibonacci/fib_test.go from [5ea0aed96e] to [0734e0cdf2].
︙ | |||
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | - + - - + + + + + | } } func TestCoding(t *testing.T) { n := New(32) for i := uint64(0); i < 4096; i++ { |
︙ |