-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
60 lines (44 loc) · 1.01 KB
/
main_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
57
58
59
60
package main
import (
"io/ioutil"
"os"
"path"
"testing"
)
func SatTester(t *testing.T, testdir string, shouldBeSat bool) {
dir := path.Join(os.Getenv("GOPATH"), "src/github.com/sema/go-sat/fixtures", testdir)
fileinfos, err := ioutil.ReadDir(dir)
if err != nil {
t.Errorf("Could not open %v", dir)
return
}
for _, fileInfo := range fileinfos {
if fileInfo.IsDir() {
continue
}
filePath := path.Join(dir, fileInfo.Name())
_, sat, err := OpenAndSolve(filePath)
if err != nil {
t.Errorf("%v returned an error", filePath)
continue
}
if sat != shouldBeSat {
satStr := "sat"
if shouldBeSat {
satStr = "unsat"
}
t.Errorf("%v returned %v", filePath, satStr)
continue
}
t.Logf("%v done", filePath)
}
}
func TestSolverOnSmallSatExamples(t *testing.T) {
SatTester(t, "small/sat", true)
}
func TestSolverOnSmallUnsatExamples(t *testing.T) {
SatTester(t, "small/unsat", false)
}
func TestSolverOnHoos50SatExamples(t *testing.T) {
SatTester(t, "hoos/50/sat", true)
}