MCPcopy
hub / github.com/mum4k/termdash / TestForPosition

Function TestForPosition

private/attrrange/attrrange_test.go:56–165  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestForPosition(t *testing.T) {
57 tests := []struct {
58 desc string
59 // if not nil, called before calling ForPosition.
60 // Can add ranges.
61 update func(*Tracker) error
62 pos int
63 want *AttrRange
64 wantErr bool
65 wantUpdateErr bool
66 }{
67 {
68 desc: "fails when no ranges given",
69 pos: 0,
70 wantErr: true,
71 },
72 {
73 desc: "fails to add a duplicate",
74 update: func(tr *Tracker) error {
75 if err := tr.Add(2, 5, 40); err != nil {
76 return err
77 }
78 return tr.Add(2, 3, 41)
79 },
80 wantUpdateErr: true,
81 },
82 {
83 desc: "fails when multiple given ranges, position falls before them",
84 update: func(tr *Tracker) error {
85 if err := tr.Add(2, 5, 40); err != nil {
86 return err
87 }
88 return tr.Add(5, 10, 41)
89 },
90 pos: 1,
91 wantErr: true,
92 },
93 {
94 desc: "multiple given options, position falls on the lower",
95 update: func(tr *Tracker) error {
96 if err := tr.Add(2, 5, 40); err != nil {
97 return err
98 }
99 return tr.Add(5, 10, 41)
100 },
101 pos: 2,
102 want: newAttrRange(2, 5, 40),
103 },
104 {
105 desc: "multiple given options, position falls between them",
106 update: func(tr *Tracker) error {
107 if err := tr.Add(2, 5, 40); err != nil {
108 return err
109 }
110 return tr.Add(5, 10, 41)
111 },
112 pos: 4,
113 want: newAttrRange(2, 5, 40),

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
ForPositionMethod · 0.95
newAttrRangeFunction · 0.85
NewTrackerFunction · 0.85
RunMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected