func TestNode_Unpack5(t *testing.T) { cb := tests.Context("kego.io/tests/data").Jauto().Sauto(parser.Parse) s := `{ "type": "multi", "sri": {"type":"system:string", "value": "b"}, "nri": {"type":"system:number", "value": 2}, "bri": {"type":"system:bool", "value": true}, "aljbi": {"type":"aljb", "value": true}, "aljni": {"type":"aljn", "value": 3.0}, "aljsi": {"type":"aljs", "value": "aljs2"} }` n := node.NewNode() err := n.Unpack(cb.Ctx(), system.MustPackString(s), false) require.NoError(t, err) assert.Equal(t, "b", n.Value.(*data.Multi).Sri.GetString(cb.Ctx()).Value()) assert.Equal(t, 2.0, n.Value.(*data.Multi).Nri.GetNumber(cb.Ctx()).Value()) assert.Equal(t, true, n.Value.(*data.Multi).Bri.GetBool(cb.Ctx()).Value()) assert.Equal(t, data.Aljb(true), *n.Value.(*data.Multi).Aljbi.GetAljb(cb.Ctx())) assert.Equal(t, data.Aljn(3.0), *n.Value.(*data.Multi).Aljni.GetAljn(cb.Ctx())) assert.Equal(t, data.Aljs("aljs2"), *n.Value.(*data.Multi).Aljsi.GetAljs(cb.Ctx())) }
func TestNode_SetValue(t *testing.T) { cb, n := data.Setup(t) test := func(t *testing.T, n *node.Node, m *data.Multi) { require.NoError(t, n.Map["js"].SetValue(cb.Ctx(), "aa")) assert.Equal(t, "aa", m.Js) require.NoError(t, n.Map["js"].SetValue(cb.Ctx(), "aa")) assert.Equal(t, "aa", m.Js) require.NoError(t, n.Map["ss"].SetValue(cb.Ctx(), "bb")) assert.Equal(t, "bb", m.Ss.Value()) require.NoError(t, n.Map["ss"].SetValue(cb.Ctx(), "bb")) assert.Equal(t, "bb", m.Ss.Value()) require.NoError(t, n.Map["jb"].SetValue(cb.Ctx(), false)) assert.Equal(t, false, m.Jb) require.NoError(t, n.Map["jb"].SetValue(cb.Ctx(), false)) assert.Equal(t, false, m.Jb) require.NoError(t, n.Map["sb"].SetValue(cb.Ctx(), true)) assert.Equal(t, true, m.Sb.Value()) require.NoError(t, n.Map["sb"].SetValue(cb.Ctx(), true)) assert.Equal(t, true, m.Sb.Value()) require.NoError(t, n.Map["jn"].SetValue(cb.Ctx(), 2.5)) assert.Equal(t, 2.5, m.Jn) require.NoError(t, n.Map["jn"].SetValue(cb.Ctx(), 2.5)) assert.Equal(t, 2.5, m.Jn) require.NoError(t, n.Map["sn"].SetValue(cb.Ctx(), 2.6)) assert.Equal(t, 2.6, m.Sn.Value()) require.NoError(t, n.Map["sn"].SetValue(cb.Ctx(), 2.6)) assert.Equal(t, 2.6, m.Sn.Value()) require.NoError(t, n.Map["aljb"].SetValue(cb.Ctx(), false)) assert.Equal(t, data.Aljb(false), *m.Aljb) require.NoError(t, n.Map["aljn"].SetValue(cb.Ctx(), 2.1)) assert.Equal(t, data.Aljn(2.1), *m.Aljn) require.NoError(t, n.Map["aljs"].SetValue(cb.Ctx(), "aljs1")) assert.Equal(t, data.Aljs("aljs1"), *m.Aljs) } data.Run(t, n, n.Value.(*data.Multi), test) }