-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathset_test.go
More file actions
43 lines (40 loc) · 916 Bytes
/
Copy pathset_test.go
File metadata and controls
43 lines (40 loc) · 916 Bytes
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
// Copyright 2024 Frederik Zipp. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package astar
import "testing"
func TestSetAddContains(t *testing.T) {
tests := []struct {
added []int
notContained []int
}{
{
added: nil,
notContained: []int{1, 2, 3},
},
{
added: []int{1, 2, 3, 4},
notContained: []int{-2, -1, 0, 5, 6},
},
{
added: []int{4, 4, 5, 9, 9, 10},
notContained: []int{0, 1, 2, 3, 6, 7, 8, 11, 12},
},
}
for _, tt := range tests {
var s set[int]
for _, v := range tt.added {
s.Add(v)
}
for _, v := range tt.added {
if !s.Contains(v) {
t.Errorf("Set of added %v should contain %v", tt.added, v)
}
}
for _, v := range tt.notContained {
if s.Contains(v) {
t.Errorf("Set of added %v should not contain %v", tt.added, v)
}
}
}
}