]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tpl/cast: Improve float
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 6 Aug 2024 19:16:07 +0000 (21:16 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 6 Aug 2024 20:26:43 +0000 (22:26 +0200)
Make it support the new upstream rational number type in Exif.

See #12718

go.mod
go.sum
tpl/cast/cast_test.go

diff --git a/go.mod b/go.mod
index c38aac9eb7a42d76ec6ac9d1c63347d6d4a2d993..8561d0e55e38395e8fa13adbe14b1b008e1b8adc 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -63,7 +63,7 @@ require (
        github.com/rogpeppe/go-internal v1.12.0
        github.com/sanity-io/litter v1.5.5
        github.com/spf13/afero v1.11.0
-       github.com/spf13/cast v1.6.0
+       github.com/spf13/cast v1.7.0
        github.com/spf13/cobra v1.8.1
        github.com/spf13/fsync v0.10.1
        github.com/spf13/pflag v1.0.5
diff --git a/go.sum b/go.sum
index cfcf2a12024f1f6e610707fb2e0a83e647e1b7ca..f54ed6fc1b4fc343df151b8418c7abd9e9f51eeb 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -431,6 +431,8 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
 github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
 github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
 github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
+github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
+github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
 github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
 github.com/spf13/fsync v0.10.1 h1:JRnB7G72b+gIBaBcpn5ibJSd7ww1iEahXSX2B8G6dSE=
index 5b4a36c3a1da5b02dba47e1e698f59c47a7bee97..a8fdc662b5a461859cf5ce0340eba8495907e9c9 100644 (file)
@@ -17,7 +17,9 @@ import (
        "html/template"
        "testing"
 
+       "github.com/bep/imagemeta"
        qt "github.com/frankban/quicktest"
+       "github.com/gohugoio/hugo/htesting/hqt"
 )
 
 func TestToInt(t *testing.T) {
@@ -85,6 +87,7 @@ func TestToFloat(t *testing.T) {
        t.Parallel()
        c := qt.New(t)
        ns := New()
+       oneThird, _ := imagemeta.NewRat[uint32](1, 3)
 
        for i, test := range []struct {
                v      any
@@ -101,6 +104,7 @@ func TestToFloat(t *testing.T) {
                {"0", 0.0},
                {float64(2.12), 2.12},
                {int64(123), 123.0},
+               {oneThird, 0.3333333333333333},
                {2, 2.0},
                {t, false},
        } {
@@ -114,6 +118,6 @@ func TestToFloat(t *testing.T) {
                }
 
                c.Assert(err, qt.IsNil, errMsg)
-               c.Assert(result, qt.Equals, test.expect, errMsg)
+               c.Assert(result, hqt.IsSameFloat64, test.expect, errMsg)
        }
 }