mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-01-02 13:03:11 +00:00
Document other behaviors
This commit is contained in:
parent
9320261c0c
commit
2837d35405
@ -50,6 +50,8 @@ type Multiaddr interface {
|
|||||||
// Decapsulate removes a Multiaddr wrapping. For example:
|
// Decapsulate removes a Multiaddr wrapping. For example:
|
||||||
//
|
//
|
||||||
// /ip4/1.2.3.4/tcp/80 decapsulate /tcp/80 = /ip4/1.2.3.4
|
// /ip4/1.2.3.4/tcp/80 decapsulate /tcp/80 = /ip4/1.2.3.4
|
||||||
|
// /ip4/1.2.3.4/tcp/80 decapsulate /udp/80 = /ip4/1.2.3.4/tcp/80
|
||||||
|
// /ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = nil
|
||||||
//
|
//
|
||||||
Decapsulate(Multiaddr) Multiaddr
|
Decapsulate(Multiaddr) Multiaddr
|
||||||
|
|
||||||
|
|||||||
@ -434,6 +434,16 @@ func TestDecapsulateComment(t *testing.T) {
|
|||||||
if rest.String() != "/ip4/1.2.3.4" {
|
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())
|
t.Fatalf("Documented behavior is not correct. Expected %v saw %v", "/ip4/1.2.3.4/", rest.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m = StringCast("/ip4/1.2.3.4/tcp/80")
|
||||||
|
rest = m.Decapsulate(StringCast("/udp/80"))
|
||||||
|
if !rest.Equal(m) {
|
||||||
|
t.Fatalf("Documented behavior is not correct. Expected %v saw %v", "/ip4/1.2.3.4/tcp/80", rest.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
m = StringCast("/ip4/1.2.3.4/tcp/80")
|
||||||
|
rest = m.Decapsulate(StringCast("/ip4/1.2.3.4"))
|
||||||
|
require.Nil(t, rest, "expected a nil multiaddr if we decapsulate everything")
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertValueForProto(t *testing.T, a Multiaddr, p int, exp string) {
|
func assertValueForProto(t *testing.T, a Multiaddr, p int, exp string) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user