aboutsummaryrefslogtreecommitdiff
path: root/ride/difficulty_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'ride/difficulty_test.go')
-rw-r--r--ride/difficulty_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/ride/difficulty_test.go b/ride/difficulty_test.go
index 142ac0a..5773376 100644
--- a/ride/difficulty_test.go
+++ b/ride/difficulty_test.go
@@ -1,6 +1,7 @@
package ride_test
import (
+ "math"
"testing"
"github.com/martinlehoux/biking_home/ride"
@@ -48,6 +49,32 @@ func TestCotacolClimbNotAtStart(t *testing.T) {
assert.InDelta(t, 98.0, climbs[0].DifficultyScore(), 1e-9)
}
+func TestCategoryOfBoundaries(t *testing.T) {
+ cases := []struct {
+ score float64
+ want ride.Category
+ }{
+ {-5, ride.CategoryNo},
+ {30, ride.CategoryNo},
+ {35, ride.CategoryFour}, // 35 is the first floor, not below it
+ {79, ride.CategoryFour},
+ {80, ride.CategoryThree},
+ {179, ride.CategoryThree},
+ {180, ride.CategoryTwo},
+ {249, ride.CategoryTwo},
+ {250, ride.CategoryOne},
+ {599, ride.CategoryOne},
+ {600, ride.CategoryHC},
+ {700, ride.CategoryHC},
+ {math.NaN(), ride.CategoryHC}, // reaches no floor, like the original switch default
+ }
+ for _, c := range cases {
+ assert.Equal(t, c.want, ride.CategoryOf(c.score), "score %v", c.score)
+ }
+ assert.Equal(t, "Cat 1", ride.CategoryOne.String())
+ assert.Equal(t, "NO", ride.CategoryNo.String())
+}
+
func TestCotacolHautacamClimbfinderReference(t *testing.T) {
r, err := ride.ParseFile(parser, "../examples/2022-07-21.Pogacar.gpx")
assert.NoError(t, err)