summaryrefslogtreecommitdiff
path: root/ride/index_test.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-04-21 10:54:11 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-04-21 10:54:11 +0200
commit8167681a317efa7b5c5176764c12e1c462f47803 (patch)
treeca4114699701c5e900c77abc12d2ea7977d7927a /ride/index_test.go
parent87850541aa6f719721209ed994b93ad4d7ab4077 (diff)
First implem of similar KOM
Diffstat (limited to 'ride/index_test.go')
-rw-r--r--ride/index_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/ride/index_test.go b/ride/index_test.go
new file mode 100644
index 0000000..e95f030
--- /dev/null
+++ b/ride/index_test.go
@@ -0,0 +1,36 @@
+package ride_test
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/bradleyjkemp/cupaloy"
+ "github.com/martinlehoux/biking_home/ride"
+ "github.com/stretchr/testify/assert"
+ "github.com/tkrajina/gpxgo/gpx"
+)
+
+func TestRideClimbLaCride(t *testing.T) {
+ gpxContent, err := gpx.ParseFile("../examples/activity_18043356988.gpx")
+ assert.NoError(t, err)
+ ride19Jan := ride.FromGPX(gpxContent)
+ gpxContent, err = gpx.ParseFile("../examples/activity_18679866717.gpx")
+ assert.NoError(t, err)
+ ride30Mar := ride.FromGPX(gpxContent)
+ gpxContent, err = gpx.ParseFile("../examples/activity_18880605641.gpx")
+ assert.NoError(t, err)
+ ride20Apr := ride.FromGPX(gpxContent)
+ index := ride.NewFlatRideClimbsIndex(30)
+ index.Insert(ride19Jan)
+ index.Insert(ride30Mar)
+ logs := []string{}
+ for _, climb := range ride20Apr.AllClimbs() {
+ if len(index.Similar(ride20Apr, climb)) > 0 {
+ logs = append(logs, fmt.Sprintf("Found similar climbs to %s", climb))
+ for _, similar := range index.Similar(ride20Apr, climb) {
+ logs = append(logs, fmt.Sprintf(" %s", similar))
+ }
+ }
+ }
+ cupaloy.SnapshotT(t, logs)
+}