-
Notifications
You must be signed in to change notification settings - Fork 5
/
import_test.go
39 lines (35 loc) · 1.09 KB
/
import_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
package ch
import (
"math"
"testing"
)
func TestImportedFileShortestPath(t *testing.T) {
g, err := ImportFromFile("data/export_pgrouting.csv", "data/export_pgrouting_vertices.csv", "data/export_pgrouting_shortcuts.csv")
if err != nil {
t.Error(err)
return
}
t.Log("TestImportedFileShortestPath is starting...")
u := int64(69618)
v := int64(5924)
correctNumShortcuts := int64(394840)
correctNumVertices := 187853
evaluatedShortcuts := g.GetShortcutsNum()
if evaluatedShortcuts != correctNumShortcuts {
t.Errorf("Number of contractions should be %d, but got %d", correctNumShortcuts, evaluatedShortcuts)
}
if len(g.Vertices) != correctNumVertices {
t.Errorf("Number of vertices should be %d, but got %d", correctNumVertices, len(g.Vertices))
}
ans, path := g.ShortestPath(u, v)
if len(path) != 160 {
t.Errorf("Num of vertices in path should be 160, but got %d", len(path))
return
}
correctCost := 19135.6581215226
if math.Abs(ans-correctCost) > eps {
t.Errorf("Cost of path should be %f, but got %f", correctCost, ans)
return
}
t.Log("TestImportedFileShortestPath is Ok!")
}