Debian Codegraph @

execution/func_to_bool_test.go

raw symbols SCIP
1 package execution_test
2
3 import (
4 "testing"
5
6 "github.com/tomwright/dasel/v3/model"
7 )
8
9 func TestFuncToBool(t *testing.T) {
10 t.Run("true bool", testCase{
11 s: `toBool(true)`,
12 out: model.NewBoolValue(true),
13 }.run)
14 t.Run("false bool", testCase{
15 s: `toBool(false)`,
16 out: model.NewBoolValue(false),
17 }.run)
18 t.Run("string true", testCase{
19 s: `toBool("true")`,
20 out: model.NewBoolValue(true),
21 }.run)
22 t.Run("string false", testCase{
23 s: `toBool("false")`,
24 out: model.NewBoolValue(false),
25 }.run)
26 t.Run("string yes", testCase{
27 s: `toBool("yes")`,
28 out: model.NewBoolValue(true),
29 }.run)
30 t.Run("string no", testCase{
31 s: `toBool("no")`,
32 out: model.NewBoolValue(false),
33 }.run)
34 t.Run("int 1", testCase{
35 s: `toBool(1)`,
36 out: model.NewBoolValue(true),
37 }.run)
38 t.Run("int 0", testCase{
39 s: `toBool(0)`,
40 out: model.NewBoolValue(false),
41 }.run)
42 t.Run("null", testCase{
43 s: `toBool(null)`,
44 out: model.NewBoolValue(false),
45 }.run)
46 }