File: data.go

package info (click to toggle)
golang-github-xtgo-set 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 148 kB
  • sloc: makefile: 2
file content (167 lines) | stat: -rw-r--r-- 3,384 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
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Copyright 2015 Kevin Gillette. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package testdata

import "reflect"

type BinTest struct {
	A, B    []int
	Inter   []int
	Union   []int
	Diff    []int
	RevDiff []int
	SymDiff []int
	IsSub   bool
	IsSuper bool
	IsInter bool
	IsEqual bool
}

func (t BinTest) sel(name string) interface{} { return reflect.ValueOf(t).FieldByName(name).Interface() }
func (t BinTest) SelSlice(name string) []int  { return t.sel(name).([]int) }
func (t BinTest) SelBool(name string) bool    { return t.sel(name).(bool) }

var BinTests = []BinTest{
	{
		// empty sets
		A:       nil,
		B:       nil,
		Inter:   nil,
		Union:   nil,
		Diff:    nil,
		RevDiff: nil,
		SymDiff: nil,
		IsSub:   true,
		IsSuper: true,
		IsInter: false,
		IsEqual: true,
	},
	{
		// identical sets
		A:       []int{1, 2, 3},
		B:       []int{1, 2, 3},
		Inter:   []int{1, 2, 3},
		Union:   []int{1, 2, 3},
		Diff:    nil,
		RevDiff: nil,
		SymDiff: nil,
		IsSub:   true,
		IsSuper: true,
		IsInter: true,
		IsEqual: true,
	},
	{
		// non-disjoint sets
		A:       []int{1, 2, 3},
		B:       []int{2, 3, 4},
		Inter:   []int{2, 3},
		Union:   []int{1, 2, 3, 4},
		Diff:    []int{1},
		RevDiff: []int{4},
		SymDiff: []int{1, 4},
		IsSub:   false,
		IsSuper: false,
		IsInter: true,
		IsEqual: false,
	},
	{
		// inverse non-disjoint sets
		A:       []int{2, 3, 4},
		B:       []int{1, 2, 3},
		Inter:   []int{2, 3},
		Union:   []int{1, 2, 3, 4},
		Diff:    []int{4},
		RevDiff: []int{1},
		SymDiff: []int{1, 4},
		IsSub:   false,
		IsSuper: false,
		IsInter: true,
		IsEqual: false,
	},
	{
		// disjoint sets
		A:       []int{1, 2, 3},
		B:       []int{4, 5, 6},
		Inter:   nil,
		Union:   []int{1, 2, 3, 4, 5, 6},
		Diff:    []int{1, 2, 3},
		RevDiff: []int{4, 5, 6},
		SymDiff: []int{1, 2, 3, 4, 5, 6},
		IsSub:   false,
		IsSuper: false,
		IsInter: false,
		IsEqual: false,
	},
	{
		// inverse disjoint sets
		A:       []int{4, 5, 6},
		B:       []int{1, 2, 3},
		Inter:   nil,
		Union:   []int{1, 2, 3, 4, 5, 6},
		Diff:    []int{4, 5, 6},
		RevDiff: []int{1, 2, 3},
		SymDiff: []int{1, 2, 3, 4, 5, 6},
		IsSub:   false,
		IsSuper: false,
		IsInter: false,
		IsEqual: false,
	},
	{
		// alternating disjoint sets
		A:       []int{1, 3, 5},
		B:       []int{2, 4, 6},
		Inter:   nil,
		Union:   []int{1, 2, 3, 4, 5, 6},
		Diff:    []int{1, 3, 5},
		RevDiff: []int{2, 4, 6},
		SymDiff: []int{1, 2, 3, 4, 5, 6},
		IsSub:   false,
		IsSuper: false,
		IsInter: false,
		IsEqual: false,
	},
	{
		// inverse alternating disjoint sets
		A:       []int{2, 4, 6},
		B:       []int{1, 3, 5},
		Inter:   nil,
		Union:   []int{1, 2, 3, 4, 5, 6},
		Diff:    []int{2, 4, 6},
		RevDiff: []int{1, 3, 5},
		SymDiff: []int{1, 2, 3, 4, 5, 6},
		IsSub:   false,
		IsSuper: false,
		IsInter: false,
		IsEqual: false,
	},
	{
		// subset
		A:       []int{2},
		B:       []int{1, 2, 3},
		Inter:   []int{2},
		Union:   []int{1, 2, 3},
		Diff:    nil,
		RevDiff: []int{1, 3},
		SymDiff: []int{1, 3},
		IsSub:   true,
		IsSuper: false,
		IsInter: true,
		IsEqual: false,
	},
	{
		// superset
		A:       []int{1, 2, 3},
		B:       []int{2},
		Inter:   []int{2},
		Union:   []int{1, 2, 3},
		Diff:    []int{1, 3},
		RevDiff: nil,
		SymDiff: []int{1, 3},
		IsSub:   false,
		IsSuper: true,
		IsInter: true,
		IsEqual: false,
	},
}