Debian Codegraph @

execution/func_index_of_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 TestFuncIndexOf(t *testing.T) {
10 t.Run("found", testCase{
11 s: `"hello world".indexOf("world")`,
12 out: model.NewIntValue(6),
13 }.run)
14 t.Run("not found", testCase{
15 s: `"hello world".indexOf("xyz")`,
16 out: model.NewIntValue(-1),
17 }.run)
18 t.Run("at start", testCase{
19 s: `"hello".indexOf("hello")`,
20 out: model.NewIntValue(0),
21 }.run)
22 t.Run("arg input", testCase{
23 s: `indexOf("hello world", "world")`,
24 out: model.NewIntValue(6),
25 }.run)
26 t.Run("empty substring", testCase{
27 s: `"hello".indexOf("")`,
28 out: model.NewIntValue(0),
29 }.run)
30 }