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