-
Notifications
You must be signed in to change notification settings - Fork 9
/
settings_test.go
50 lines (40 loc) · 1.03 KB
/
settings_test.go
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
// Copyright (c) The Test Authors
// SPDX-License-Identifier: MPL-2.0
package test
import (
"testing"
"github.com/google/go-cmp/cmp/cmpopts"
)
var cmpSortSlices = Cmp(cmpopts.SortSlices(func(i, j int) bool {
return i < j
}))
func TestCmp_Eq(t *testing.T) {
a := []int{3, 5, 1, 6, 7}
b := []int{1, 7, 6, 3, 5}
Eq(t, a, b, cmpSortSlices)
}
func TestCmp_NotEq(t *testing.T) {
a := []int{3, 5, 1, 6, 0}
b := []int{1, 7, 6, 3, 5}
NotEq(t, a, b, cmpSortSlices)
}
func TestCmp_SliceContains(t *testing.T) {
a := [][]int{{1}, {1, 2}}
SliceContains(t, a, []int{2, 1}, cmpSortSlices)
}
func TestCmp_SliceNotContains(t *testing.T) {
a := [][]int{{1}, {1, 2}}
SliceNotContains(t, a, []int{3, 1}, cmpSortSlices)
}
func TestCmp_MapContainsValues(t *testing.T) {
m1 := map[string][]int{
"one": {1, 3, 5, 7},
}
MapContainsValues(t, m1, [][]int{{7, 5, 1, 3}}, cmpSortSlices)
}
func TestCmp_MapNotContainsValues(t *testing.T) {
m1 := map[string][]int{
"one": {1, 3, 5, 7},
}
MapNotContainsValues(t, m1, [][]int{{0, 5, 1, 3}}, cmpSortSlices)
}