-
Notifications
You must be signed in to change notification settings - Fork 2
/
list_test.go
47 lines (43 loc) · 1 KB
/
list_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Copyright 2018-2023 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
package semver
import (
"sort"
"testing"
"github.com/stretchr/testify/require"
)
func TestListSorting(t *testing.T) {
list := []*Version{
MustParse("2.1.1"),
MustParse("1.0.0-beta"),
MustParse("1.0.0-beta.11"),
MustParse("1.0.0-alpha.beta"),
MustParse("1.0.0-alpha.1"),
MustParse("1.0.0-rc.1"),
MustParse("1.0.1"),
MustParse("1.0.0"),
MustParse("1.0.0-alpha"),
MustParse("1.0.0-beta.2"),
MustParse("1.1.1"),
}
ordered := []*Version{
MustParse("1.0.0-alpha"),
MustParse("1.0.0-alpha.1"),
MustParse("1.0.0-alpha.beta"),
MustParse("1.0.0-beta"),
MustParse("1.0.0-beta.2"),
MustParse("1.0.0-beta.11"),
MustParse("1.0.0-rc.1"),
MustParse("1.0.0"),
MustParse("1.0.1"),
MustParse("1.1.1"),
MustParse("2.1.1"),
}
sort.Sort(List(list))
for i := range list {
require.True(t, list[i].Equal(ordered[i]))
}
}