mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
tpl/math: Refactor Mod with cast
It makes the code smaller
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
488631fe0a
commit
76dc811c65
@@ -259,13 +259,17 @@ func TestMod(t *testing.T) {
|
||||
{3, 1, int64(0)},
|
||||
{3, 0, false},
|
||||
{0, 3, int64(0)},
|
||||
{3.1, 2, false},
|
||||
{3, 2.1, false},
|
||||
{3.1, 2.1, false},
|
||||
{3.1, 2, int64(1)},
|
||||
{3, 2.1, int64(1)},
|
||||
{3.1, 2.1, int64(1)},
|
||||
{int8(3), int8(2), int64(1)},
|
||||
{int16(3), int16(2), int64(1)},
|
||||
{int32(3), int32(2), int64(1)},
|
||||
{int64(3), int64(2), int64(1)},
|
||||
{"3", "2", int64(1)},
|
||||
{"3.1", "2", false},
|
||||
{"aaa", "0", false},
|
||||
{"3", "aaa", false},
|
||||
} {
|
||||
errMsg := fmt.Sprintf("[%d] %v", i, test)
|
||||
|
||||
@@ -296,9 +300,9 @@ func TestModBool(t *testing.T) {
|
||||
{3, 1, true},
|
||||
{3, 0, nil},
|
||||
{0, 3, true},
|
||||
{3.1, 2, nil},
|
||||
{3, 2.1, nil},
|
||||
{3.1, 2.1, nil},
|
||||
{3.1, 2, false},
|
||||
{3, 2.1, false},
|
||||
{3.1, 2.1, false},
|
||||
{int8(3), int8(3), true},
|
||||
{int8(3), int8(2), false},
|
||||
{int16(3), int16(3), true},
|
||||
@@ -307,6 +311,11 @@ func TestModBool(t *testing.T) {
|
||||
{int32(3), int32(2), false},
|
||||
{int64(3), int64(3), true},
|
||||
{int64(3), int64(2), false},
|
||||
{"3", "3", true},
|
||||
{"3", "2", false},
|
||||
{"3.1", "2", nil},
|
||||
{"aaa", "0", nil},
|
||||
{"3", "aaa", nil},
|
||||
} {
|
||||
errMsg := fmt.Sprintf("[%d] %v", i, test)
|
||||
|
||||
|
Reference in New Issue
Block a user