MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / TestValues

Function TestValues

values_test.go:9–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestValues(t *testing.T) {
10 sv := StringValue{"hello"}
11 assert.Equal(t, "hello", ReturnValue{sv.ToAV()}.String())
12 assert.False(t, ReturnValue{sv.ToAV()}.Empty())
13
14 iv := IntValue{42}
15 assert.Equal(t, int64(42), ReturnValue{iv.ToAV()}.Int())
16 assert.True(t, ReturnValue{iv.ToAV()}.Present())
17
18 fv := FloatValue{3.14}
19 assert.InDelta(t, 3.14, ReturnValue{fv.ToAV()}.Float(), 0.001)
20
21 bv := BytesValue{[]byte{1, 2, 3, 4}}
22 assert.Equal(t, []byte{1, 2, 3, 4}, ReturnValue{bv.ToAV()}.Bytes())
23
24 assert.True(t, ReturnValue{}.Empty())
25 assert.False(t, ReturnValue{}.Present())
26
27 // Ensure that return value indicates presence even with empty and zero values
28 assert.True(t, ReturnValue{BytesValue{[]byte{}}.ToAV()}.Present())
29 assert.True(t, ReturnValue{IntValue{0}.ToAV()}.Present())
30 assert.True(t, ReturnValue{StringValue{""}.ToAV()}.Present())
31}

Callers

nothing calls this directly

Calls 11

ToAVMethod · 0.95
ToAVMethod · 0.95
ToAVMethod · 0.95
ToAVMethod · 0.95
EmptyMethod · 0.80
IntMethod · 0.80
PresentMethod · 0.80
FloatMethod · 0.80
BytesMethod · 0.80
ToAVMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected