-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(basicnode): increase test coverage for int and map types (#454)
- Loading branch information
Showing
2 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package basicnode_test | ||
|
||
import ( | ||
qt "github.com/frankban/quicktest" | ||
"github.com/ipld/go-ipld-prime/must" | ||
"github.com/ipld/go-ipld-prime/node/basicnode" | ||
"testing" | ||
) | ||
|
||
func TestBasicInt(t *testing.T) { | ||
m := basicnode.NewInt(3) | ||
b := m.Prototype().NewBuilder() | ||
b.AssignInt(4) | ||
n := b.Build() | ||
u := basicnode.NewUint(5) | ||
qt.Check(t, must.Int(m), qt.Equals, int64(3)) | ||
qt.Check(t, must.Int(n), qt.Equals, int64(4)) | ||
qt.Check(t, must.Int(u), qt.Equals, int64(5)) | ||
} | ||
|
||
func TestIntErrors(t *testing.T) { | ||
x := basicnode.NewInt(3) | ||
|
||
_, err := x.LookupByIndex(0) | ||
errExpect := `func called on wrong kind: "LookupByIndex" called on a int node \(kind: int\), but only makes sense on list` | ||
qt.Check(t, err, qt.ErrorMatches, errExpect) | ||
|
||
_, err = x.LookupByString("n") | ||
errExpect = `func called on wrong kind: "LookupByString" called on a int node \(kind: int\), but only makes sense on map` | ||
qt.Check(t, err, qt.ErrorMatches, errExpect) | ||
|
||
_, err = x.LookupByNode(x) | ||
errExpect = `func called on wrong kind: "LookupByNode" called on a int node \(kind: int\), but only makes sense on map` | ||
qt.Check(t, err, qt.ErrorMatches, errExpect) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters