2018-01-06 01:34:31 +00:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
2018-01-06 04:50:45 +00:00
|
|
|
"fmt"
|
2018-01-06 01:34:31 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/anacrolix/missinggo"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPeerIdString(t *testing.T) {
|
|
|
|
for _, _case := range []struct {
|
|
|
|
id string
|
|
|
|
s string
|
|
|
|
}{
|
|
|
|
{"\x1cNJ}\x9c\xc7\xc4o\x94<\x9b\x8c\xc2!I\x1c\a\xec\x98n", "1c4e4a7d9cc7c46f943c9b8cc221491c07ec986e"},
|
|
|
|
{"-FD51W\xe4-LaZMk0N8ZLA7", "-FD51W\xe4-4c615a4d6b304e385a4c4137"},
|
|
|
|
} {
|
2018-01-06 04:50:45 +00:00
|
|
|
var pi PeerID
|
2018-01-06 01:34:31 +00:00
|
|
|
missinggo.CopyExact(&pi, _case.id)
|
|
|
|
assert.EqualValues(t, _case.s, pi.String())
|
2018-01-06 04:50:45 +00:00
|
|
|
assert.EqualValues(t, fmt.Sprintf("%q", _case.s), fmt.Sprintf("%q", pi))
|
2018-01-06 01:34:31 +00:00
|
|
|
}
|
|
|
|
}
|