github.com/ipld/go-ipld-prime@v0.21.0/node/tests/stringSpecs.go (about) 1 package tests 2 3 import ( 4 "testing" 5 6 qt "github.com/frankban/quicktest" 7 8 "github.com/ipld/go-ipld-prime/datamodel" 9 ) 10 11 func SpecTestString(t *testing.T, np datamodel.NodePrototype) { 12 t.Run("string node", func(t *testing.T) { 13 nb := np.NewBuilder() 14 err := nb.AssignString("asdf") 15 qt.Check(t, err, qt.IsNil) 16 n := nb.Build() 17 18 qt.Check(t, n.Kind(), qt.Equals, datamodel.Kind_String) 19 qt.Check(t, n.IsNull(), qt.IsFalse) 20 x, err := n.AsString() 21 qt.Check(t, err, qt.IsNil) 22 qt.Check(t, x, qt.Equals, "asdf") 23 }) 24 }