summaryrefslogtreecommitdiffstats
path: root/pkg/integration/components/int_matcher.go
blob: c80a60c859618a31d694184655b2c0faa9ed87c8 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package components

import (
	"fmt"
)

type IntMatcher struct {
	*Matcher[int]
}

func (self *IntMatcher) EqualsInt(target int) *IntMatcher {
	self.appendRule(matcherRule[int]{
		name: fmt.Sprintf("equals '%d'", target),
		testFn: func(value int) (bool, string) {
			return value == target, fmt.Sprintf("Expected '%d' to equal '%d'", value, target)
		},
	})

	return self
}

func (self *IntMatcher) GreaterThan(target int) *IntMatcher {
	self.appendRule(matcherRule[int]{
		name: fmt.Sprintf("greater than '%d'", target),
		testFn: func(value int) (bool, string) {
			return value > target, fmt.Sprintf("Expected '%d' to greater than '%d'", value, target)
		},
	})

	return self
}

func (self *IntMatcher) LessThan(target int) *IntMatcher {
	self.appendRule(matcherRule[int]{
		name: fmt.Sprintf("less than '%d'", target),
		testFn: func(value int) (bool, string) {
			return value < target, fmt.Sprintf("Expected '%d' to less than '%d'", value, target)
		},
	})

	return self
}

func AnyInt() *IntMatcher {
	return &IntMatcher{Matcher: &Matcher[int]{}}
}

func EqualsInt(target int) *IntMatcher {
	return AnyInt().EqualsInt(target)
}

func GreaterThan(target int) *IntMatcher {
	return AnyInt().GreaterThan(target)
}

func LessThan(target int) *IntMatcher {
	return AnyInt().LessThan(target)
}