(t *testing.T)
| 19 | } |
| 20 | |
| 21 | func TestEncodeInt(t *testing.T) { |
| 22 | var inttests = []struct { |
| 23 | i int64 |
| 24 | encoding string |
| 25 | }{ |
| 26 | {0, "00"}, |
| 27 | {1, "01"}, |
| 28 | {10, "0a"}, |
| 29 | {23, "17"}, |
| 30 | {24, "1818"}, |
| 31 | {25, "1819"}, |
| 32 | {100, "1864"}, |
| 33 | {255, "18ff"}, |
| 34 | {256, "190100"}, |
| 35 | {1000, "1903e8"}, |
| 36 | {1000000, "1a000f4240"}, |
| 37 | {1000000000000, "1b000000e8d4a51000"}, |
| 38 | {-1, "20"}, |
| 39 | {-10, "29"}, |
| 40 | {-100, "3863"}, |
| 41 | {-1000, "3903e7"}, |
| 42 | {-9223372036854775808, "3b7fffffffffffffff"}, |
| 43 | } |
| 44 | for _, test := range inttests { |
| 45 | var b bytes.Buffer |
| 46 | e := NewEncoder(&b) |
| 47 | |
| 48 | if err := e.EncodeInt(test.i); err != nil { |
| 49 | t.Errorf("Encode. err: %v", err) |
| 50 | } |
| 51 | exp := fromHex(test.encoding) |
| 52 | |
| 53 | if !bytes.Equal(exp, b.Bytes()) { |
| 54 | t.Errorf("%d expected to encode to %v, actual %v", test.i, exp, b.Bytes()) |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | func TestEncodeByteString(t *testing.T) { |
| 60 | var bytesTests = []struct { |
nothing calls this directly
no test coverage detected