github.com/LdDl/ch@v1.7.8/vanilla_dijkstra_test.go (about) 1 package ch 2 3 import ( 4 "math" 5 "testing" 6 ) 7 8 const ( 9 eps = 0.0001 10 ) 11 12 func TestVanillaShortestPath(t *testing.T) { 13 g := Graph{} 14 err := graphFromCSV(&g, "data/pgrouting_osm.csv") 15 if err != nil { 16 t.Error(err) 17 } 18 t.Log("TestShortestPath is starting...") 19 u := int64(69618) 20 v := int64(5924) 21 ans, path := g.VanillaShortestPath(u, v) 22 if len(path) != 160 { 23 t.Errorf("Num of vertices in path should be 160, but got %d", len(path)) 24 return 25 } 26 correctCost := 19135.6581215226 27 if math.Abs(ans-correctCost) > eps { 28 t.Errorf("Cost of path should be %f, but got %f", correctCost, ans) 29 return 30 } 31 t.Log("TestVanillaShortestPath is Ok!") 32 }