forked from keys-pub/keys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detect_test.go
37 lines (26 loc) · 1.19 KB
/
detect_test.go
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
package keys_test
import (
"testing"
"github.com/keys-pub/keys"
"github.com/stretchr/testify/require"
)
func TestDetect(t *testing.T) {
_, typ := keys.DetectEncoding([]byte("kex132yw8ht5p8cetl2jmvknewjawt9xwzdlrk2pyxlnwjyqrdq0dawqqph077"))
require.Equal(t, keys.IDEncoding, typ)
_, typ = keys.DetectEncoding([]byte("kex132yw8ht5p8cetl2jmvknewjawt9xwzdlrk2pyxlnwjyqrdq0dawqqph07"))
require.Equal(t, keys.IDEncoding, typ)
_, typ = keys.DetectEncoding([]byte("kex132yw8ht5p8cetl2mvknewjawt9xwzdlrk2pyxlnwjyqrdq0dawqqph077"))
require.Equal(t, keys.IDEncoding, typ)
_, typ = keys.DetectEncoding([]byte("kex132yw8ht5p8cetl2mvknewjawt9xwzdlrk2pyxlnwjyqrdq0dawqqph077 "))
require.Equal(t, keys.IDEncoding, typ)
_, typ = keys.DetectEncoding([]byte("BEGIN MESSAGE. ok END MESSAGE."))
require.Equal(t, keys.SaltpackEncoding, typ)
_, typ = keys.DetectEncoding([]byte("BEGIN MESSAGE. ok "))
require.Equal(t, keys.SaltpackEncoding, typ)
_, typ = keys.DetectEncoding([]byte("BEGIN MESSAGE"))
require.Equal(t, keys.SaltpackEncoding, typ)
_, typ = keys.DetectEncoding([]byte{})
require.Equal(t, keys.UnknownEncoding, typ)
_, typ = keys.DetectEncoding(nil)
require.Equal(t, keys.UnknownEncoding, typ)
}