summaryrefslogtreecommitdiff
path: root/vendor/github.com/smartystreets/assertions/filter.go
blob: 7c46ab8e35c1e01f607d51bd46388a5a76241f9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package assertions

import "fmt"

const (
	success                = ""
	needExactValues        = "This assertion requires exactly %d comparison values (you provided %d)."
	needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)."
	needFewerValues        = "This assertion allows %d or fewer comparison values (you provided %d)."
)

func need(needed int, expected []interface{}) string {
	if len(expected) != needed {
		return fmt.Sprintf(needExactValues, needed, len(expected))
	}
	return success
}

func atLeast(minimum int, expected []interface{}) string {
	if len(expected) < 1 {
		return needNonEmptyCollection
	}
	return success
}

func atMost(max int, expected []interface{}) string {
	if len(expected) > max {
		return fmt.Sprintf(needFewerValues, max, len(expected))
	}
	return success
}