Skip to content

Commit

Permalink
ua: tests for NodeID.String()
Browse files Browse the repository at this point in the history
Fixes #517
  • Loading branch information
magiconair committed Dec 5, 2021
1 parent 073ad3a commit 50e4ba4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ua/node_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,37 @@ func TestNodeIDJSON(t *testing.T) {
}
})
}

func TestNodeIDToString(t *testing.T) {
tests := []struct {
s string
want string
}{
{"i=123", "i=123"},
{"s=123", "s=123"},
{"b=MTIz", "b=MTIz"},
{"g=F11BD41E-2DF5-41D3-8CE2-A37D22D1E469", "g=F11BD41E-2DF5-41D3-8CE2-A37D22D1E469"},

{"ns=0;i=123", "i=123"},
{"ns=0;s=123", "s=123"},
{"ns=0;b=MTIz", "b=MTIz"},
{"ns=0;g=F11BD41E-2DF5-41D3-8CE2-A37D22D1E469", "g=F11BD41E-2DF5-41D3-8CE2-A37D22D1E469"},

{"ns=1;i=123", "ns=1;i=123"},
{"ns=1;s=123", "ns=1;s=123"},
{"ns=1;b=MTIz", "ns=1;b=MTIz"},
{"ns=1;g=F11BD41E-2DF5-41D3-8CE2-A37D22D1E469", "ns=1;g=F11BD41E-2DF5-41D3-8CE2-A37D22D1E469"},
}

for _, tt := range tests {
t.Run(tt.s, func(t *testing.T) {
n, err := ParseNodeID(tt.s)
if err != nil {
t.Fatal(err)
}
if got, want := n.String(), tt.want; got != want {
t.Fatalf("got %s want %s", got, want)
}
})
}
}

0 comments on commit 50e4ba4

Please sign in to comment.