Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
satta committed Mar 15, 2021
1 parent 92bb3fa commit 1cdcb73
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions communityid_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package gommunityid

import (
"testing"
)

func TestCommunityIDMake(t *testing.T) {
cid, err := GetCommunityIDByVersion(1, 42)
if err != nil {
t.Fatal(err)
}
cidv1, ok := cid.(CommunityIDv1)
if !ok {
t.Fatal("can't assert expected type")
}
if cidv1.Seed != 42 {
t.Fatalf("wrong seed: %d", cidv1.Seed)
}
}

func TestCommunityIDMakeFail(t *testing.T) {
_, err := GetCommunityIDByVersion(23, 42)
if err == nil {
t.Fatal(err)
}
}
2 changes: 2 additions & 0 deletions communityid_v1_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gommunityid

import (
"fmt"
"net"
"testing"

Expand Down Expand Up @@ -31,6 +32,7 @@ func verifyTuples(t *testing.T, ts []testSet, mf makeFunc) {
assert.Equal(t, tset.Base64Seed0, cid0.CalcBase64(ft))
assert.Equal(t, tset.HexSeed0, cid0.CalcHex(ft))
assert.Equal(t, tset.Base64Seed1, cid1.CalcBase64(ft))
assert.Equal(t, tset.HexSeed0, fmt.Sprintf("1:%x", cid0.Calc(ft)))
}
}

Expand Down

0 comments on commit 1cdcb73

Please sign in to comment.