示例#1
0
文件: node_ext_test.go 项目: kego/ke
func TestNode_SetValueZero3(t *testing.T) {
	cb, n := data.Empty(t)
	f, ok := system.GetTypeFromCache(cb.Ctx(), "kego.io/tests/data", "face")
	assert.True(t, ok)
	err := n.SetValueZero(cb.Ctx(), true, f)
	assert.HasError(t, err, "VHOSYBMDQL")
}
示例#2
0
文件: node_ext_test.go 项目: kego/ke
func TestNode_SetValueZero2(t *testing.T) {
	cb, n := data.Empty(t)
	test := func(t *testing.T, n *node.Node, m *data.Multi) {
		sstring, ok := system.GetTypeFromCache(cb.Ctx(), "kego.io/system", "string")
		assert.True(t, ok)
		snumber, ok := system.GetTypeFromCache(cb.Ctx(), "kego.io/system", "number")
		assert.True(t, ok)

		require.NoError(t, n.Map["ss"].SetValueZero(cb.Ctx(), true, sstring))
		assert.Nil(t, m.Ss)

		require.NoError(t, n.Map["sn"].SetValueZero(cb.Ctx(), false, snumber))
		assert.NotNil(t, m.Sn)

		require.NoError(t, n.Map["mnri"].SetValueZero(cb.Ctx(), true, nil))
		assert.Nil(t, m.Mnri)

		require.NoError(t, n.Map["mi"].SetValueZero(cb.Ctx(), false, nil))
		assert.NotNil(t, m.Mi)
		assert.Equal(t, 0, len(m.Mi))

		require.NoError(t, n.Map["anri"].SetValueZero(cb.Ctx(), true, nil))
		assert.Nil(t, m.Anri)

		require.NoError(t, n.Map["ai"].SetValueZero(cb.Ctx(), false, nil))
		assert.NotNil(t, m.Ai)
		assert.Equal(t, 0, len(m.Ai))

	}
	data.Run(t, n, n.Value.(*data.Multi), test)

}