Files
filou/keys/encoding_test.go
T
2014-10-24 20:03:41 -04:00

44 lines
781 B
Go

package keys
import (
"encoding/json"
"reflect"
"testing"
. "github.com/didiercrunch/filou/helper"
)
func TestRSAPrivateKeyJsonification(t *testing.T) {
key := &RSAPrivateKey{B(1023), B(2112), B(328723), B(2332), 89}
data, err := json.Marshal(key)
if err != nil {
t.Error(err)
return
}
key2 := new(RSAPrivateKey)
if err := json.Unmarshal(data, key2); err != nil {
t.Error(err)
return
}
if !reflect.DeepEqual(key, key2) {
t.Fail()
}
}
func TestRSAPublicKeyJsonification(t *testing.T) {
key := &RSAPublicKey{B(1023), 89}
data, err := json.Marshal(key)
if err != nil {
t.Error(err)
return
}
key2 := new(RSAPublicKey)
if err := json.Unmarshal(data, key2); err != nil {
t.Error(err)
return
}
if !reflect.DeepEqual(key, key2) {
t.Fail()
}
}