| 1 | package base85 |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "fmt" |
| 6 | ) |
| 7 | |
| 8 | func TestChunked (t *testing.T) { |
| 9 | a := []byte("M") |
| 10 | fmt.Printf("a %#v\n", a) |
| 11 | b := make([]byte, EncodedLen(len(a))) |
| 12 | encodeChunk(b, a) |
| 13 | fmt.Printf("b %#v\n", b) |
| 14 | c := make([]byte, DecodedLen(len(b))) |
| 15 | decodeChunk(c, b) |
| 16 | fmt.Printf("c %#v\n", c) |
| 17 | |
| 18 | a = []byte("Ma") |
| 19 | fmt.Printf("a %#v\n", a) |
| 20 | b = make([]byte, EncodedLen(len(a))) |
| 21 | encodeChunk(b, a) |
| 22 | fmt.Printf("b %#v\n", b) |
| 23 | c = make([]byte, DecodedLen(len(b))) |
| 24 | decodeChunk(c, b) |
| 25 | fmt.Printf("c %#v\n", c) |
| 26 | |
| 27 | a = []byte("Man") |
| 28 | fmt.Printf("a %#v\n", a) |
| 29 | b = make([]byte, EncodedLen(len(a))) |
| 30 | encodeChunk(b, a) |
| 31 | fmt.Printf("b %#v\n", b) |
| 32 | c = make([]byte, DecodedLen(len(b))) |
| 33 | decodeChunk(c, b) |
| 34 | fmt.Printf("c %#v\n", c) |
| 35 | |
| 36 | a = []byte("Man ") |
| 37 | fmt.Printf("a %#v\n", a) |
| 38 | b = make([]byte, EncodedLen(len(a))) |
| 39 | encodeChunk(b, a) |
| 40 | fmt.Printf("b %#v\n", b) |
| 41 | c = make([]byte, DecodedLen(len(b))) |
| 42 | decodeChunk(c, b) |
| 43 | fmt.Printf("c %#v\n", c) |
| 44 | |
| 45 | a = []byte("Manual") |
| 46 | fmt.Printf("a %#v\n", a) |
| 47 | b = make([]byte, EncodedLen(len(a))) |
| 48 | n := Encode(b, a) |
| 49 | fmt.Printf("b %#v %d\n", b, n) |
| 50 | c = make([]byte, DecodedLen(len(b))) |
| 51 | n, _ = Decode(c, b) |
| 52 | fmt.Printf("c %#v %d\n", c, n) |
| 53 | |
| 54 | a = []byte("Manual") |
| 55 | fmt.Printf("a %s\n", a) |
| 56 | sb := EncodeToString(a) + "\"" |
| 57 | fmt.Printf("b %#v\n", sb) |
| 58 | sc, err := DecodeString(sb) |
| 59 | fmt.Printf("c %s %s\n", sc, err) |
| 60 | } |