aboutsummaryrefslogtreecommitdiff
path: root/weed/util/inits_test.go
blob: f2c9b701fcfb1cd499538ee8bfcac1d320926bb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package util

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestHumanReadableIntsMax(t *testing.T) {
	assert.Equal(t, "1-2 ...", HumanReadableIntsMax(2, 1, 2, 3))
	assert.Equal(t, "1 3 ...", HumanReadableIntsMax(2, 1, 3, 5))
}

func TestHumanReadableInts(t *testing.T) {
	assert.Equal(t, "1-3", HumanReadableInts(1, 2, 3))
	assert.Equal(t, "1 3", HumanReadableInts(1, 3))
	assert.Equal(t, "1 3 5", HumanReadableInts(5, 1, 3))
	assert.Equal(t, "1-3 5", HumanReadableInts(1, 2, 3, 5))
	assert.Equal(t, "1-3 5 7-9", HumanReadableInts(7, 9, 8, 1, 2, 3, 5))
}