github.com/LdDl/ch@v1.7.8/export_test.go (about)

     1  package ch
     2  
     3  import (
     4  	"log"
     5  	"testing"
     6  )
     7  
     8  func TestExport(t *testing.T) {
     9  	g := Graph{}
    10  	err := graphFromCSV(&g, "data/pgrouting_osm.csv")
    11  	if err != nil {
    12  		t.Error(err)
    13  	}
    14  	t.Log("Please wait until contraction hierarchy is prepared")
    15  	g.PrepareContractionHierarchies()
    16  	t.Log("TestExport is starting...")
    17  	correctNumShortcuts := int64(394840)
    18  	correctNumVertices := 187853
    19  	evaluatedShortcuts := g.GetShortcutsNum()
    20  	if evaluatedShortcuts != correctNumShortcuts {
    21  		t.Errorf("Number of contractions should be %d, but got %d", correctNumShortcuts, evaluatedShortcuts)
    22  	}
    23  	if len(g.Vertices) != correctNumVertices {
    24  		t.Errorf("Number of vertices should be %d, but got %d", correctNumVertices, len(g.Vertices))
    25  	}
    26  	err = g.ExportToFile("data/export_pgrouting.csv")
    27  	if err != nil {
    28  		t.Error(err)
    29  		return
    30  	}
    31  	log.Println("TestExport is Ok!")
    32  }