-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommons_test.go
56 lines (50 loc) · 1.1 KB
/
commons_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
51
52
53
54
55
56
package main
import (
"testing"
db "github.com/squirlyfoxy/ronny/database"
)
func TestContains(t *testing.T) { //Strings
s := []string{"a", "b", "c"}
if !db.Contains(s, "a") {
t.Error("Contains() failed")
}
if db.Contains(s, "d") {
t.Error("Contains() failed")
}
}
func TestContainsOnType(t *testing.T) {
s := []db.OnType{db.CAN_GLOBALLY_TAKE, db.CAN_TAKE}
if !db.ContainsOnType(s, db.CAN_GLOBALLY_TAKE) {
t.Error("ContainsOnType() failed")
}
if db.ContainsOnType(s, db.CAN_REMOVE) {
t.Error("ContainsOnType() failed")
}
}
func TestCheckTableRule(t *testing.T) {
table := db.Table{
Name: "test",
Rule: db.Rule{
RuleTypes: []db.RuleType{
{
Can: []db.OnType{db.CAN_GLOBALLY_TAKE},
},
},
},
}
if !db.CheckTableRule(table, db.CAN_GLOBALLY_TAKE) {
t.Error("CheckTableRule() failed")
}
if db.CheckTableRule(table, db.CAN_REMOVE) {
t.Error("CheckTableRule() failed")
}
}
func TestRemove(t *testing.T) { //Strings
s := []string{"a", "b", "c"}
if len(db.Remove(s, "a")) != 2 {
t.Error("Remove() failed")
}
if len(db.Remove(s, "d")) != 3 {
t.Error("Remove() failed")
}
}