initial commit
[govpp.git] / vendor / github.com / onsi / gomega / matchers / have_len_matcher.go
1 package matchers
2
3 import (
4         "fmt"
5         "github.com/onsi/gomega/format"
6 )
7
8 type HaveLenMatcher struct {
9         Count int
10 }
11
12 func (matcher *HaveLenMatcher) Match(actual interface{}) (success bool, err error) {
13         length, ok := lengthOf(actual)
14         if !ok {
15                 return false, fmt.Errorf("HaveLen matcher expects a string/array/map/channel/slice.  Got:\n%s", format.Object(actual, 1))
16         }
17
18         return length == matcher.Count, nil
19 }
20
21 func (matcher *HaveLenMatcher) FailureMessage(actual interface{}) (message string) {
22         return fmt.Sprintf("Expected\n%s\nto have length %d", format.Object(actual, 1), matcher.Count)
23 }
24
25 func (matcher *HaveLenMatcher) NegatedFailureMessage(actual interface{}) (message string) {
26         return fmt.Sprintf("Expected\n%s\nnot to have length %d", format.Object(actual, 1), matcher.Count)
27 }