Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go
2880 views
1
// untested sections: 2
2
3
package matchers
4
5
import (
6
"fmt"
7
8
"github.com/onsi/gomega/format"
9
)
10
11
type HaveCapMatcher struct {
12
Count int
13
}
14
15
func (matcher *HaveCapMatcher) Match(actual any) (success bool, err error) {
16
length, ok := capOf(actual)
17
if !ok {
18
return false, fmt.Errorf("HaveCap matcher expects a array/channel/slice. Got:\n%s", format.Object(actual, 1))
19
}
20
21
return length == matcher.Count, nil
22
}
23
24
func (matcher *HaveCapMatcher) FailureMessage(actual any) (message string) {
25
return fmt.Sprintf("Expected\n%s\nto have capacity %d", format.Object(actual, 1), matcher.Count)
26
}
27
28
func (matcher *HaveCapMatcher) NegatedFailureMessage(actual any) (message string) {
29
return fmt.Sprintf("Expected\n%s\nnot to have capacity %d", format.Object(actual, 1), matcher.Count)
30
}
31
32