MCPcopy Create free account
hub / github.com/AdRoll/baker / TestSlice

Function TestSlice

filter/slice_test.go:10–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestSlice(t *testing.T) {
11 fields := map[string]baker.FieldIndex{
12 "1st": 0,
13 "2nd": 1,
14 "3rd": 2,
15 }
16
17 fieldByName := func(s string) (baker.FieldIndex, bool) {
18 idx, ok := fields[s]
19 return idx, ok
20 }
21
22 tests := []struct {
23 name string
24 src string
25 dst string
26 start int
27 end int
28 record []byte
29 want []byte
30 wantInitErr bool
31 wantErr bool
32 }{
33 {
34 name: "empty src",
35 src: "",
36 dst: "2nd",
37 end: 5,
38 wantInitErr: true,
39 },
40 {
41 name: "empty dst",
42 src: "1st",
43 dst: "",
44 end: 5,
45 wantInitErr: true,
46 },
47 {
48 name: "wrong length",
49 src: "1st",
50 dst: "2nd",
51 wantInitErr: true,
52 },
53 {
54 name: "negative length",
55 src: "1st",
56 dst: "2nd",
57 end: -2,
58 wantInitErr: true,
59 },
60 {
61 name: "start > end",
62 src: "1st",
63 dst: "3rd",
64 start: 3,
65 end: 2,
66 wantInitErr: true,
67 },

Callers

nothing calls this directly

Calls 6

ParseMethod · 0.95
ProcessMethod · 0.95
GetMethod · 0.95
ToTextMethod · 0.95
NewSliceFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected