diff options
Diffstat (limited to 'helpers/hugo_test.go')
-rw-r--r-- | helpers/hugo_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/helpers/hugo_test.go b/helpers/hugo_test.go index d901395e2..b71517f71 100644 --- a/helpers/hugo_test.go +++ b/helpers/hugo_test.go @@ -17,6 +17,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestHugoVersion(t *testing.T) { @@ -26,3 +27,21 @@ func TestHugoVersion(t *testing.T) { assert.Equal(t, "0.15.2-DEV", hugoVersion(0.15, 2, "-DEV")) assert.Equal(t, "0.17.3", hugoVersionNoSuffix(0.16+0.01, 3)) } + +func TestCompareVersions(t *testing.T) { + require.Equal(t, 0, compareVersions(0.20, 0, 0.20)) + require.Equal(t, 0, compareVersions(0.20, 0, float32(0.20))) + require.Equal(t, 0, compareVersions(0.20, 0, float64(0.20))) + require.Equal(t, 1, compareVersions(0.19, 1, 0.20)) + require.Equal(t, 1, compareVersions(0.19, 3, "0.20.2")) + require.Equal(t, -1, compareVersions(0.19, 1, 0.01)) + require.Equal(t, 1, compareVersions(0, 1, 3)) + require.Equal(t, 1, compareVersions(0, 1, int32(3))) + require.Equal(t, 1, compareVersions(0, 1, int64(3))) + require.Equal(t, 0, compareVersions(0.20, 0, "0.20")) + require.Equal(t, 0, compareVersions(0.20, 1, "0.20.1")) + require.Equal(t, -1, compareVersions(0.20, 1, "0.20")) + require.Equal(t, 1, compareVersions(0.20, 0, "0.20.1")) + require.Equal(t, 1, compareVersions(0.20, 1, "0.20.2")) + require.Equal(t, 1, compareVersions(0.21, 1, "0.22.1")) +} |