Include types from gonavitia/navitia
This commit is contained in:
parent
82769f923e
commit
24b1102761
157 changed files with 26062 additions and 116 deletions
44
types/line_test.go
Normal file
44
types/line_test.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Test_Line_Unmarshal tests unmarshalling for Line.
|
||||
// As the unmarshalling is done in-house, this allows us to check that the custom UnmarshalJSON function correctly
|
||||
//
|
||||
// This launches both a "correct" and "incorrect" subtest, allowing us to test both cases.
|
||||
// If we expect no errors but we get one, the test fails
|
||||
// If we expect an error but we don't get one, the test fails
|
||||
func Test_Line_Unmarshal(t *testing.T) {
|
||||
testUnmarshal(t, testData["line"], reflect.TypeOf(Line{}))
|
||||
}
|
||||
|
||||
// BenchmarkLineUnmarshal benchmarks Line unmarshalling via subbenchmarks
|
||||
func BenchmarkLineUnmarshal(b *testing.B) {
|
||||
// Get the bench data
|
||||
data := testData["line"].bench
|
||||
if len(data) == 0 {
|
||||
b.Skip("No data to test")
|
||||
}
|
||||
|
||||
// Run function generator, allowing parallel run
|
||||
runGen := func(in []byte) func(*testing.B) {
|
||||
return func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
l := &Line{}
|
||||
_ = l.UnmarshalJSON(in)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over all corpus
|
||||
for name, datum := range data {
|
||||
// Get run function
|
||||
runFunc := runGen(datum)
|
||||
|
||||
// Run it !
|
||||
b.Run(name, runFunc)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue