Tests: Add unit tests

This commit is contained in:
graciousgrey 2023-07-21 16:31:35 +02:00
parent 60d280430e
commit 69d302248c
2 changed files with 34 additions and 0 deletions

View file

@ -175,3 +175,22 @@ func TestData_CellID(t *testing.T) {
assert.Equal(t, "s2:100c9acde614", data.CellID())
})
}
func TestData_IsHDR(t *testing.T) {
t.Run("true", func(t *testing.T) {
data := Data{
ImageType: 3,
TakenAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
}
assert.True(t, data.IsHDR())
})
t.Run("false", func(t *testing.T) {
data := Data{
ImageType: 2,
TakenAt: time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC),
}
assert.False(t, data.IsHDR())
})
}

View file

@ -75,3 +75,18 @@ func TestGpsCoord(t *testing.T) {
assert.Equal(t, float64(0), r)
})
}
func TestClipLat(t *testing.T) {
assert.Equal(t, 10.254852777777785, clipLat(100.25485277777778))
assert.Equal(t, 89.25485277777778, clipLat(89.25485277777778))
assert.Equal(t, 10.254852777777785, clipLat(190.25485277777778))
assert.Equal(t, -10.254852777777785, clipLat(-100.25485277777778))
assert.Equal(t, -89.25485277777778, clipLat(-89.25485277777778))
assert.Equal(t, -10.254852777777785, clipLat(-190.25485277777778))
}
func TestNormalizeGPS(t *testing.T) {
assert.Equal(t, 100.25485277777778, normalizeCoord(100.25485277777778, 120.25485277777778))
assert.Equal(t, 110.25485277777778, normalizeCoord(-130.25485277777778, 120.25485277777778))
assert.Equal(t, -120.25485277777778, normalizeCoord(120.25485277777778, 120.25485277777778))
}