Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mf
go-multiaddr
Commits
a778a9db
Commit
a778a9db
authored
Jun 18, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a round-trip test
parent
dea70a9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
multiaddr_test.go
multiaddr_test.go
+20
-0
No files found.
multiaddr_test.go
View file @
a778a9db
...
...
@@ -433,3 +433,23 @@ func TestBinaryRepresentation(t *testing.T) {
t
.
Errorf
(
"expected %x, got %x"
,
expected
,
ma
.
Bytes
())
}
}
func
TestRoundTrip
(
t
*
testing
.
T
)
{
for
_
,
s
:=
range
[]
string
{
"/unix/a/b/c/d"
,
"/ip4/127.0.0.1/tcp/123"
,
"/ip4/127.0.0.1/udp/123"
,
"/ip4/127.0.0.1/udp/123/ip6/::"
,
"/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP"
,
"/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP/unix/a/b/c"
,
}
{
ma
,
err
:=
NewMultiaddr
(
s
)
if
err
!=
nil
{
t
.
Errorf
(
"error when parsing %q: %s"
,
s
,
err
)
continue
}
if
ma
.
String
()
!=
s
{
t
.
Errorf
(
"failed to round trip %q"
,
s
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment