Skip to content

Commit

Permalink
make test function names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmach committed Feb 24, 2018
1 parent 829a6f8 commit ff7b075
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 70 deletions.
6 changes: 3 additions & 3 deletions annotate/edgecases_test.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/paulmach/osm" "github.com/paulmach/osm"
) )


func TestEdgeCase_ChildCreatedAfterParent(t *testing.T) { func TestEdgeCase_childCreatedAfterParent(t *testing.T) {
// example: way 43680701, node 370250076 // example: way 43680701, node 370250076
// way 4708608, node 29974559 // way 4708608, node 29974559
// Way's first version is 4 days after node's first version. // Way's first version is 4 days after node's first version.
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestEdgeCase_ChildCreatedAfterParent(t *testing.T) {
}) })
} }


func TestEdgeCase_NodeDeletedBetweenParents(t *testing.T) { func TestEdgeCase_nodeDeletedBetweenParents(t *testing.T) {
// example: node 321452894, way 28831147 // example: node 321452894, way 28831147


nodes := osm.Nodes{ nodes := osm.Nodes{
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestEdgeCase_NodeDeletedBetweenParents(t *testing.T) {
} }
} }


func TestEdgeCase_NodeRedacted(t *testing.T) { func TestEdgeCase_nodeRedacted(t *testing.T) {
// example: way 159081205, node 376130526 // example: way 159081205, node 376130526
// Oh the license change. Nodes have 1 non-visible version. // Oh the license change. Nodes have 1 non-visible version.


Expand Down
4 changes: 2 additions & 2 deletions annotate/order_test.go
Expand Up @@ -49,7 +49,7 @@ func TestChildFirstOrdering(t *testing.T) {
} }
} }


func TestChildFirstOrdering_Cycle(t *testing.T) { func TestChildFirstOrdering_cycle(t *testing.T) {
relations := osm.Relations{ relations := osm.Relations{
{ID: 1, Version: 1, Members: osm.Members{ {ID: 1, Version: 1, Members: osm.Members{
{Type: osm.TypeRelation, Ref: 2}, {Type: osm.TypeRelation, Ref: 2},
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestChildFirstOrdering_Walk(t *testing.T) {
} }
} }


func TestChildFirstOrdering_MissingRelation(t *testing.T) { func TestChildFirstOrdering_missingRelation(t *testing.T) {
relations := osm.Relations{ relations := osm.Relations{
{ID: 2, Members: osm.Members{ {ID: 2, Members: osm.Members{
{Type: osm.TypeRelation, Ref: 3}, {Type: osm.TypeRelation, Ref: 3},
Expand Down
10 changes: 5 additions & 5 deletions annotate/relation_test.go
Expand Up @@ -47,7 +47,7 @@ func TestRelation(t *testing.T) {
} }
} }


func TestRelation_Reverse(t *testing.T) { func TestRelation_reverse(t *testing.T) {
ways := osm.Ways{ ways := osm.Ways{
{ {
ID: 1, Version: 1, Visible: true, Nodes: osm.WayNodes{ ID: 1, Version: 1, Visible: true, Nodes: osm.WayNodes{
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestRelation_Reverse(t *testing.T) {
}) })
} }


func TestRelation_Polygon(t *testing.T) { func TestRelation_polygon(t *testing.T) {
ways := osm.Ways{ ways := osm.Ways{
{ {
ID: 1, ID: 1,
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestRelation_Polygon(t *testing.T) {
} }
} }


func TestRelation_Circular(t *testing.T) { func TestRelation_circular(t *testing.T) {
relations := osm.Relations{ relations := osm.Relations{
&osm.Relation{ID: 1, Version: 1, Visible: true, Timestamp: time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), &osm.Relation{ID: 1, Version: 1, Visible: true, Timestamp: time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
Members: osm.Members{ Members: osm.Members{
Expand Down Expand Up @@ -325,7 +325,7 @@ func TestRelation_Circular(t *testing.T) {
} }
} }


func TestRelation_SelfCircular(t *testing.T) { func TestRelation_selfCircular(t *testing.T) {
rs := osm.Relations{ rs := osm.Relations{
{ID: 1, Version: 1, Visible: true, Timestamp: time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), {ID: 1, Version: 1, Visible: true, Timestamp: time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
Members: osm.Members{ Members: osm.Members{
Expand Down Expand Up @@ -373,7 +373,7 @@ func TestRelation_SelfCircular(t *testing.T) {
} }
} }


func BenchmarkRelation(b *testing.B) { func BenchmarkRelations(b *testing.B) {
id := osm.RelationID(2714790) id := osm.RelationID(2714790)
filename := fmt.Sprintf("testdata/relation_%d.osm", id) filename := fmt.Sprintf("testdata/relation_%d.osm", id)


Expand Down
2 changes: 1 addition & 1 deletion annotate/way_test.go
Expand Up @@ -41,7 +41,7 @@ func TestWays(t *testing.T) {
} }
} }


func TestWays_ChildFilter(t *testing.T) { func TestWays_childFilter(t *testing.T) {
nodes := osm.Nodes{ nodes := osm.Nodes{
{ID: 1, Version: 1, Lat: 1, Lon: 1, Visible: true}, {ID: 1, Version: 1, Lat: 1, Lon: 1, Visible: true},
{ID: 1, Version: 2, Lat: 2, Lon: 2, Visible: true}, {ID: 1, Version: 2, Lat: 2, Lon: 2, Visible: true},
Expand Down
10 changes: 10 additions & 0 deletions changeset.go
Expand Up @@ -45,6 +45,16 @@ func (c *Changeset) ObjectID() ObjectID {
return c.ID.ObjectID() return c.ID.ObjectID()
} }


// Bounds returns the bounds of the changeset as a bounds object.
func (c *Changeset) Bounds() *Bounds {
return &Bounds{
MinLat: c.MinLat,
MaxLat: c.MaxLat,
MinLon: c.MinLon,
MaxLon: c.MaxLon,
}
}

// Comment is a helper and returns the changeset comment from the tag. // Comment is a helper and returns the changeset comment from the tag.
func (c *Changeset) Comment() string { func (c *Changeset) Comment() string {
return c.Tags.Find("comment") return c.Tags.Find("comment")
Expand Down
26 changes: 21 additions & 5 deletions changeset_test.go
Expand Up @@ -131,7 +131,7 @@ func TestChangeset(t *testing.T) {
} }
} }


func TestChangesetOpen(t *testing.T) { func TestChangeset_open(t *testing.T) {
data := []byte(` data := []byte(`
<changeset id="40309372" user="Bahntech" uid="3619264" created_at="2016-06-26T21:26:41Z" open="true" min_lat="51.484563" min_lon="12.0995042" max_lat="51.484563" max_lon="12.0995042" comments_count="0"> <changeset id="40309372" user="Bahntech" uid="3619264" created_at="2016-06-26T21:26:41Z" open="true" min_lat="51.484563" min_lon="12.0995042" max_lat="51.484563" max_lon="12.0995042" comments_count="0">
<tag k="comment" v="updated fire hydrant details with OsmHydrant"/> <tag k="comment" v="updated fire hydrant details with OsmHydrant"/>
Expand All @@ -149,7 +149,7 @@ func TestChangesetOpen(t *testing.T) {
} }
} }


func TestChangesetTags(t *testing.T) { func TestChangeset_tags(t *testing.T) {
data := []byte(` data := []byte(`
<changeset id="123123"> <changeset id="123123">
<tag k="comment" v="changeset comment"/> <tag k="comment" v="changeset comment"/>
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestChangesetTags(t *testing.T) {
} }
} }


func TestChangesetBound(t *testing.T) { func TestChangeset_bounds(t *testing.T) {
data := []byte(` data := []byte(`
<changeset id="36947173" created_at="2016-02-01T22:00:56Z" closed_at="2016-02-01T23:05:06Z" open="false" num_changes="9" user="florijn11" uid="1319603" min_lat="51.5871887" max_lat="51.6032569" min_lon="5.3214071" max_lon="5.33106" comments_count="0"> <changeset id="36947173" created_at="2016-02-01T22:00:56Z" closed_at="2016-02-01T23:05:06Z" open="false" num_changes="9" user="florijn11" uid="1319603" min_lat="51.5871887" max_lat="51.6032569" min_lon="5.3214071" max_lon="5.33106" comments_count="0">
<tag k="version" v="2.4"/> <tag k="version" v="2.4"/>
Expand All @@ -210,9 +210,25 @@ func TestChangesetBound(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("unmarshal error: %v", err) t.Fatalf("unmarshal error: %v", err)
} }

if v := c.MinLat; v != 51.5871887 {
t.Errorf("incorrect value, got %v", v)
}

if v := c.MaxLat; v != 51.6032569 {
t.Errorf("incorrect value, got %v", v)
}

if v := c.MinLon; v != 5.3214071 {
t.Errorf("incorrect value, got %v", v)
}

if v := c.MaxLon; v != 5.33106 {
t.Errorf("incorrect value, got %v", v)
}
} }


func TestChangesetComment(t *testing.T) { func TestChangeset_comments(t *testing.T) {
data := []byte(` data := []byte(`
<changeset id="40303151" user="Glen Bundrick" uid="4173877" created_at="2016-06-26T15:37:47Z" closed_at="2016-06-26T15:37:48Z" open="false" min_lat="34.6591676" min_lon="-81.8789825" max_lat="34.6594167" max_lon="-81.8788142" comments_count="3"> <changeset id="40303151" user="Glen Bundrick" uid="4173877" created_at="2016-06-26T15:37:47Z" closed_at="2016-06-26T15:37:48Z" open="false" min_lat="34.6591676" min_lon="-81.8789825" max_lat="34.6594167" max_lon="-81.8788142" comments_count="3">
<tag k="comment" v="Recent Doublewide addition"/> <tag k="comment" v="Recent Doublewide addition"/>
Expand Down Expand Up @@ -262,7 +278,7 @@ func TestChangesetComment(t *testing.T) {
} }
} }


func TestChangesetMarshalXML(t *testing.T) { func TestChangeset_MarshalXML(t *testing.T) {
cs := Changeset{ cs := Changeset{
ID: 123, ID: 123,
} }
Expand Down
4 changes: 2 additions & 2 deletions element_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"testing" "testing"
) )


func TestElementID_ParseElementID(t *testing.T) { func TestParseElementID(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
string string string string
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestElementID_ParseElementID(t *testing.T) {
} }
} }


func TestElementImplementations(t *testing.T) { func TestElement_implementations(t *testing.T) {
var _ Element = &Node{} var _ Element = &Node{}
var _ Element = &Way{} var _ Element = &Way{}
var _ Element = &Relation{} var _ Element = &Relation{}
Expand Down
2 changes: 1 addition & 1 deletion feature_test.go
Expand Up @@ -43,7 +43,7 @@ func TestFeature_String(t *testing.T) {
} }
} }


func TestFeatureID_ParseFeatureID(t *testing.T) { func TestParseFeatureID(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
id FeatureID id FeatureID
Expand Down
4 changes: 2 additions & 2 deletions internal/mputil/join_test.go
Expand Up @@ -83,7 +83,7 @@ func TestJoin(t *testing.T) {
} }
} }


func TestJoinLineString_SinglePointLine(t *testing.T) { func TestJoin_lineString_singlePointLine(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
input []Segment input []Segment
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestJoinLineString_SinglePointLine(t *testing.T) {
} }
} }


func TestJoinLineString_DanglingLine(t *testing.T) { func TestJoin_lineString_danglingLine(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
input []Segment input []Segment
Expand Down
4 changes: 2 additions & 2 deletions internal/mputil/mputil_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/paulmach/orb" "github.com/paulmach/orb"
) )


func TestMultiSegmentToRing_NoAnnotation(t *testing.T) { func TestMultiSegment_ToRing_noAnnotation(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
orientation orb.Orientation orientation orb.Orientation
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestMultiSegmentToRing_NoAnnotation(t *testing.T) {
} }
} }


func TestMultiSegmentToRing_Annotation(t *testing.T) { func TestMultiSegment_ToRing_annotation(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
orientation orb.Orientation orientation orb.Orientation
Expand Down
34 changes: 17 additions & 17 deletions marshal_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"time" "time"
) )


func TestMarshal_Node(t *testing.T) { func TestNode_Marshal(t *testing.T) {
c := loadChange(t, "testdata/changeset_38162210.osc") c := loadChange(t, "testdata/changeset_38162210.osc")
n := c.Create.Nodes[12] n := c.Create.Nodes[12]


Expand All @@ -32,7 +32,7 @@ func TestMarshal_Node(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestMarshal_NodeRoundoff(t *testing.T) { func TestNode_Marshal_roundoff(t *testing.T) {
c := loadChange(t, "testdata/changeset_38162210.osc") c := loadChange(t, "testdata/changeset_38162210.osc")
n := c.Create.Nodes[194] n := c.Create.Nodes[194]


Expand All @@ -42,7 +42,7 @@ func TestMarshal_NodeRoundoff(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestMarshal_Nodes(t *testing.T) { func TestNodes_Marshal(t *testing.T) {
c := loadChange(t, "testdata/changeset_38162210.osc") c := loadChange(t, "testdata/changeset_38162210.osc")
ns1 := c.Create.Nodes ns1 := c.Create.Nodes


Expand All @@ -57,7 +57,7 @@ func TestMarshal_Nodes(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestMarshal_Way(t *testing.T) { func TestWay_Marshal(t *testing.T) {
c := loadChange(t, "testdata/changeset_38162210.osc") c := loadChange(t, "testdata/changeset_38162210.osc")
w := c.Create.Ways[5] w := c.Create.Ways[5]


Expand All @@ -72,7 +72,7 @@ func TestMarshal_Way(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestMarshal_WayUpdates(t *testing.T) { func TestWay_Marshal_updates(t *testing.T) {
o := loadOSM(t, "testdata/way-updates.osm") o := loadOSM(t, "testdata/way-updates.osm")
checkMarshal(t, o) checkMarshal(t, o)


Expand All @@ -81,7 +81,7 @@ func TestMarshal_WayUpdates(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestMarshal_Relation(t *testing.T) { func TestRelation_Marshal(t *testing.T) {
c := loadChange(t, "testdata/changeset_38162206.osc") c := loadChange(t, "testdata/changeset_38162206.osc")
r := c.Create.Relations[0] r := c.Create.Relations[0]


Expand All @@ -96,7 +96,7 @@ func TestMarshal_Relation(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestMarshal_RelationUpdates(t *testing.T) { func TestRelation_Marshal_updates(t *testing.T) {
o := loadOSM(t, "testdata/relation-updates.osm") o := loadOSM(t, "testdata/relation-updates.osm")
checkMarshal(t, o) checkMarshal(t, o)


Expand All @@ -105,7 +105,7 @@ func TestMarshal_RelationUpdates(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestMarshal_RelationMemberLocation(t *testing.T) { func TestRelation_Marshal_memberLocation(t *testing.T) {
o := &OSM{ o := &OSM{
Relations: Relations{ Relations: Relations{
{ {
Expand All @@ -121,7 +121,7 @@ func TestMarshal_RelationMemberLocation(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func TestProtobufRelation_Orientation(t *testing.T) { func TestRelation_Marshal_protobufOrientation(t *testing.T) {
o := &OSM{ o := &OSM{
Relations: Relations{ Relations: Relations{
{ {
Expand All @@ -140,7 +140,7 @@ func TestProtobufRelation_Orientation(t *testing.T) {
checkMarshal(t, o) checkMarshal(t, o)
} }


func BenchmarkMarshalXML(b *testing.B) { func BenchmarkChange_MarshalXML(b *testing.B) {
filename := "testdata/changeset_38162206.osc" filename := "testdata/changeset_38162206.osc"
data := readFile(b, filename) data := readFile(b, filename)


Expand All @@ -160,7 +160,7 @@ func BenchmarkMarshalXML(b *testing.B) {
} }
} }


func BenchmarkMarshalProto(b *testing.B) { func BenchmarkChangeSet_Marshal(b *testing.B) {
cs := &Changeset{ cs := &Changeset{
ID: 38162206, ID: 38162206,
UserID: 2744209, UserID: 2744209,
Expand All @@ -178,7 +178,7 @@ func BenchmarkMarshalProto(b *testing.B) {
} }
} }


func BenchmarkMarshalWayUpdates(b *testing.B) { func BenchmarkUnmarshalWays(b *testing.B) {
o := loadOSM(b, "testdata/way-updates.osm") o := loadOSM(b, "testdata/way-updates.osm")
ways := o.Ways ways := o.Ways


Expand All @@ -190,7 +190,7 @@ func BenchmarkMarshalWayUpdates(b *testing.B) {
} }
} }


func BenchmarkMarshalRelationUpdates(b *testing.B) { func BenchmarkUnmarshalRelations(b *testing.B) {
o := loadOSM(b, "testdata/relation-updates.osm") o := loadOSM(b, "testdata/relation-updates.osm")
relations := o.Relations relations := o.Relations


Expand All @@ -202,7 +202,7 @@ func BenchmarkMarshalRelationUpdates(b *testing.B) {
} }
} }


func BenchmarkMarshalProtoGZIP(b *testing.B) { func BenchmarkChangeset_Marshal_gzip(b *testing.B) {
cs := &Changeset{ cs := &Changeset{
ID: 38162206, ID: 38162206,
UserID: 2744209, UserID: 2744209,
Expand Down Expand Up @@ -231,7 +231,7 @@ func BenchmarkMarshalProtoGZIP(b *testing.B) {
} }
} }


func BenchmarkUnmarshalXML(b *testing.B) { func BenchmarkChangeset_UnmarshalXML(b *testing.B) {
filename := "testdata/changeset_38162206.osc" filename := "testdata/changeset_38162206.osc"
data := readFile(b, filename) data := readFile(b, filename)


Expand All @@ -246,7 +246,7 @@ func BenchmarkUnmarshalXML(b *testing.B) {
} }
} }


func BenchmarkUnmarshalProto(b *testing.B) { func BenchmarkUnmarshalChangeset(b *testing.B) {
cs := &Changeset{ cs := &Changeset{
ID: 38162206, ID: 38162206,
UserID: 2744209, UserID: 2744209,
Expand All @@ -268,7 +268,7 @@ func BenchmarkUnmarshalProto(b *testing.B) {
} }
} }
} }
func BenchmarkUnmarshalProtoGZIP(b *testing.B) { func BenchmarkUnmarshalChangeset_gzip(b *testing.B) {
cs := &Changeset{ cs := &Changeset{
ID: 38162206, ID: 38162206,
UserID: 2744209, UserID: 2744209,
Expand Down

0 comments on commit ff7b075

Please sign in to comment.