Path: blob/main/vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go
2880 views
// untested sections: 212package matchers34import (5"fmt"67"github.com/onsi/gomega/format"8)910type HaveCapMatcher struct {11Count int12}1314func (matcher *HaveCapMatcher) Match(actual any) (success bool, err error) {15length, ok := capOf(actual)16if !ok {17return false, fmt.Errorf("HaveCap matcher expects a array/channel/slice. Got:\n%s", format.Object(actual, 1))18}1920return length == matcher.Count, nil21}2223func (matcher *HaveCapMatcher) FailureMessage(actual any) (message string) {24return fmt.Sprintf("Expected\n%s\nto have capacity %d", format.Object(actual, 1), matcher.Count)25}2627func (matcher *HaveCapMatcher) NegatedFailureMessage(actual any) (message string) {28return fmt.Sprintf("Expected\n%s\nnot to have capacity %d", format.Object(actual, 1), matcher.Count)29}303132