-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunctionSet_test.go
More file actions
74 lines (59 loc) · 1.44 KB
/
functionSet_test.go
File metadata and controls
74 lines (59 loc) · 1.44 KB
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
package set
import (
"errors"
"testing"
)
func containsAll(interface{}) (bool, error) {
return true, nil
}
func containsNone(interface{}) (bool, error) {
return false, nil
}
func containsErrors(interface{}) (bool, error) {
return false, errors.New("This is always wrong")
}
func TestFunctionSetContains(t *testing.T) {
elements := []interface{}{1, 2, 3, 4, "Hello", "World", "!", true, false}
a := functionSet{containsAll}
b := functionSet{containsNone}
c := functionSet{containsErrors}
for _, element := range elements {
if yes, err := a.Contains(element); err != nil {
t.Fatal(err)
} else if !yes {
t.Error("%v should be in a", element)
}
if yes, err := b.Contains(element); err != nil {
t.Fatal(err)
} else if yes {
t.Error("%v should not be in a", element)
}
if _, err := c.Contains(element); err == nil {
t.Error("Empty error")
}
}
}
func TestFunctionSetCountable(t *testing.T) {
a := functionSet{}
if a.Countable() {
t.Error("This should not be countable")
}
}
func TestFunctionSetDefFinite(t *testing.T) {
a := functionSet{}
if a.DefinitelyFinite() {
t.Error("This should not be definitely finite")
}
}
func TestFunctionSetCardinality(t *testing.T) {
a := functionSet{}
if _, err := a.Cardinality(); err == nil {
t.Error("Error should not be nil")
}
}
func TestFunctionSetList(t *testing.T) {
a := functionSet{}
if _, err := a.List(); err == nil {
t.Error("Error should not be nil")
}
}