forked from p53841790/wheat-cache
test(value): add test value
This commit is contained in:
parent
bcacc83df6
commit
eb53a976e2
|
@ -84,3 +84,35 @@ func TestValue_InferValue(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, f, -1.2)
|
require.Equal(t, f, -1.2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValue_ChangeValue(t *testing.T) {
|
||||||
|
value := NewValue()
|
||||||
|
oldLen := value.GetLength()
|
||||||
|
chanageLen := value.ChangeValueLength(func() {
|
||||||
|
value.SetString("小葵花课堂开课了")
|
||||||
|
})
|
||||||
|
require.Equal(t, chanageLen, int64(value.GetLength()-oldLen))
|
||||||
|
|
||||||
|
lens := value.ChangeValueLength(func() {
|
||||||
|
value.SetInt(100)
|
||||||
|
})
|
||||||
|
require.Equal(t, lens, int64(-16))
|
||||||
|
|
||||||
|
lengs := value.ChangeValueLength(func() {
|
||||||
|
value.SetFloat64(9.99)
|
||||||
|
})
|
||||||
|
require.Equal(t, lengs, int64(0))
|
||||||
|
|
||||||
|
value = NewValue()
|
||||||
|
lengs = value.ChangeValueLength(func() {
|
||||||
|
value.SetFloat64(10.99)
|
||||||
|
})
|
||||||
|
require.Equal(t, lengs, int64(0))
|
||||||
|
|
||||||
|
value = NewValue()
|
||||||
|
value.SetString("909awdawdawd")
|
||||||
|
lengs = value.ChangeValueLength(func() {
|
||||||
|
value.SetString("9akjwbddddddddddddddddddddddddddddddddddddddddddddd")
|
||||||
|
})
|
||||||
|
require.Equal(t, lengs, int64(39))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue