MCPcopy Create free account
hub / github.com/gavv/httpexpect / TestMatch_Getters

Function TestMatch_Getters

match_test.go:98–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestMatch_Getters(t *testing.T) {
99 matches := []string{"m0", "m1", "m2"}
100 names := []string{"", "n1", "n2"}
101
102 t.Run("length", func(t *testing.T) {
103 reporter := newMockReporter(t)
104
105 value := NewMatch(reporter, matches, names)
106
107 innerValue := value.Length()
108 assert.Equal(t, 3.0, innerValue.Raw())
109
110 value.chain.assert(t, success)
111 innerValue.chain.assert(t, success)
112 })
113
114 t.Run("submatch", func(t *testing.T) {
115 reporter := newMockReporter(t)
116
117 value := NewMatch(reporter, matches, names)
118
119 for n := range matches {
120 innerValue := value.Submatch(n)
121 assert.Equal(t, matches[n], innerValue.Raw())
122
123 value.chain.assert(t, success)
124 innerValue.chain.assert(t, success)
125 }
126 })
127
128 t.Run("submatch out of range", func(t *testing.T) {
129 reporter := newMockReporter(t)
130
131 value := NewMatch(reporter, matches, names)
132
133 innerValue := value.Submatch(3)
134 assert.NotNil(t, innerValue)
135
136 value.chain.assert(t, failure)
137 innerValue.chain.assert(t, failure)
138 })
139
140 t.Run("named submatch", func(t *testing.T) {
141 reporter := newMockReporter(t)
142
143 value := NewMatch(reporter, matches, names)
144
145 for n := range matches {
146 if names[n] == "" {
147 continue
148 }
149 innerValue := value.NamedSubmatch(names[n])
150 assert.Equal(t, matches[n], innerValue.Raw())
151
152 value.chain.assert(t, success)
153 innerValue.chain.assert(t, success)
154 }
155 })

Callers

nothing calls this directly

Calls 8

LengthMethod · 0.95
SubmatchMethod · 0.95
NamedSubmatchMethod · 0.95
newMockReporterFunction · 0.85
NewMatchFunction · 0.85
assertMethod · 0.80
EqualMethod · 0.45
RawMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…