diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-08-06 21:16:07 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-08-06 22:26:43 +0200 |
commit | 10891f305ed95136381a29b0015f8e0d043f93d8 (patch) | |
tree | 007285244db4d2bfcf69151b4a074c59c8c9ed3c /tpl | |
parent | c07e94fa6d0303b962670d592fefb01a76ee5d6f (diff) | |
download | hugo-10891f305ed95136381a29b0015f8e0d043f93d8.tar.gz hugo-10891f305ed95136381a29b0015f8e0d043f93d8.zip |
tpl/cast: Improve float
Make it support the new upstream rational number type in Exif.
See #12718
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/cast/cast_test.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tpl/cast/cast_test.go b/tpl/cast/cast_test.go index 5b4a36c3a..a8fdc662b 100644 --- a/tpl/cast/cast_test.go +++ b/tpl/cast/cast_test.go @@ -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) } } |