mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-05-22 01:09:26 +00:00
Fix comment on Decapsulate
This commit is contained in:
parent
e8c0913a8e
commit
9320261c0c
@ -47,9 +47,9 @@ type Multiaddr interface {
|
|||||||
//
|
//
|
||||||
Encapsulate(Multiaddr) Multiaddr
|
Encapsulate(Multiaddr) Multiaddr
|
||||||
|
|
||||||
// Decapsultate removes a Multiaddr wrapping. For example:
|
// Decapsulate removes a Multiaddr wrapping. For example:
|
||||||
//
|
//
|
||||||
// /ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = /tcp/80
|
// /ip4/1.2.3.4/tcp/80 decapsulate /tcp/80 = /ip4/1.2.3.4
|
||||||
//
|
//
|
||||||
Decapsulate(Multiaddr) Multiaddr
|
Decapsulate(Multiaddr) Multiaddr
|
||||||
|
|
||||||
|
|||||||
@ -427,6 +427,15 @@ func TestEncapsulate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDecapsulateComment(t *testing.T) {
|
||||||
|
// shows the behavior from the interface comment
|
||||||
|
m := StringCast("/ip4/1.2.3.4/tcp/80")
|
||||||
|
rest := m.Decapsulate(StringCast("/tcp/80"))
|
||||||
|
if rest.String() != "/ip4/1.2.3.4" {
|
||||||
|
t.Fatalf("Documented behavior is not correct. Expected %v saw %v", "/ip4/1.2.3.4/", rest.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func assertValueForProto(t *testing.T, a Multiaddr, p int, exp string) {
|
func assertValueForProto(t *testing.T, a Multiaddr, p int, exp string) {
|
||||||
t.Logf("checking for %s in %s", ProtocolWithCode(p).Name, a)
|
t.Logf("checking for %s in %s", ProtocolWithCode(p).Name, a)
|
||||||
fv, err := a.ValueForProtocol(p)
|
fv, err := a.ValueForProtocol(p)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user