File: rules_test.go

package info (click to toggle)
golang-github-zclconf-go-cty 1.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,464 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 684 bytes parent folder | download
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
package set

// testRules is a rules implementation that is used for testing. It only
// accepts ints as values, and it has a Hash function that just returns the
// given value modulo 16 so that we can easily and dependably test the
// situation where two non-equivalent values have the same hash value.
type testRules struct{}

func newTestRules() Rules[int] {
	return testRules{}
}

func (r testRules) Hash(val int) int {
	return val % 16
}

func (r testRules) Equivalent(val1 int, val2 int) bool {
	return val1 == val2
}

func (r testRules) SameRules(other Rules[int]) bool {
	// All testRules values are equal, so type-checking is enough.
	_, ok := other.(testRules)
	return ok
}