-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase32check_test.go
More file actions
61 lines (55 loc) · 2.18 KB
/
base32check_test.go
File metadata and controls
61 lines (55 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2013-2014 The btcsuite developers
// Copyright (c) 2018 Saeed Rasooli <saeed.gnu@gmail.com>
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package crock32_test
// var checkEncodingStringTests = []struct {
// version byte
// in string
// out string
// }{
// {20, "", "3MNQE1X"},
// {20, " ", "B2Kr6dBE"},
// {20, "-", "B3jv1Aft"},
// {20, "0", "B482yuaX"},
// {20, "1", "B4CmeGAC"},
// {20, "-1", "mM7eUf6kB"},
// {20, "11", "mP7BMTDVH"},
// {20, "abc", "4QiVtDjUdeq"},
// {20, "1234598760", "ZmNb8uQn5zvnUohNCEPP"},
// {20, "abcdefghijklmnopqrstuvwxyz", "K2RYDcKfupxwXdWhSAxQPCeiULntKm63UXyx5MvEH2"},
// {20, "00000000000000000000000000000000000000000000000000000000000000", "bi1EWXwJay2udZVxLJozuTb8Meg4W9c6xnmJaRDjg6pri5MBAxb9XwrpQXbtnqEoRV5U2pixnFfwyXC8tRAVC8XxnjK"},
// }
// func TestBase32Check(t *testing.T) {
// for x, test := range checkEncodingStringTests {
// // test encoding
// if res := crock32.CheckEncode([]byte(test.in), test.version); res != test.out {
// t.Errorf("CheckEncode test in=%#v failed: got %s, want: %s", test.in, res, test.out)
// }
// // test decoding
// res, version, err := crock32.CheckDecode(test.out)
// if err != nil {
// t.Errorf("CheckDecode test #%d failed with err: %v", x, err)
// } else if version != test.version {
// t.Errorf("CheckDecode test #%d failed: got version: %d want: %d", x, version, test.version)
// } else if string(res) != test.in {
// t.Errorf("CheckDecode test #%d failed: got: %s want: %s", x, res, test.in)
// }
// }
// // test the two decoding failure cases
// // case 1: checksum error
// _, _, err := crock32.CheckDecode("3MNQE1Y")
// if err != crock32.ErrChecksum {
// t.Error("Checkdecode test failed, expected ErrChecksum")
// }
// // case 2: invalid formats (string lengths below 5 mean the version byte and/or the checksum
// // bytes are missing).
// testString := ""
// for len := 0; len < 4; len++ {
// // make a string of length `len`
// _, _, err = crock32.CheckDecode(testString)
// if err != crock32.ErrInvalidFormat {
// t.Error("Checkdecode test failed, expected ErrInvalidFormat")
// }
// }
// }