forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaturalsort_test.go
41 lines (34 loc) · 951 Bytes
/
naturalsort_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
// Copyright 2017 FoxyUtils ehf. All rights reserved.
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting [email protected].
package algo_test
import (
"testing"
"github.com/unidoc/unioffice/algo"
)
func TestSort(t *testing.T) {
tests := []struct {
a, b string
}{
{"rId1", "rId2"},
{"rId1", "rId10"},
{"rId2", "rId10"},
{"rId5", "rId10"},
{"rId5", "rId15"},
{"rId5", "rId51"},
{"rId1a", "rId1b"},
}
for _, tc := range tests {
if !algo.NaturalLess(tc.a, tc.b) {
t.Errorf("bad sort, expected %s < %s", tc.a, tc.b)
} else {
// no need to check if it failed the first time
if algo.NaturalLess(tc.b, tc.a) {
t.Errorf("bad sort, expected %s > %s", tc.b, tc.a)
}
}
}
}