This file is indexed.

/usr/share/gocode/src/github.com/skarademir/naturalsort/naturalsort_test.go is in golang-github-skarademir-naturalsort-dev 0.0~git20150715.0.69a5d87-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
package naturalsort

import (
	"reflect"
	"sort"
	"testing"
)

func TestSortValid(t *testing.T) {
	cases := []struct {
		data, expected []string
	}{
		{
			nil,
			nil,
		},
		{
			[]string{},
			[]string{},
		},
		{
			[]string{"a"},
			[]string{"a"},
		},
		{
			[]string{"0"},
			[]string{"0"},
		},
		{
			[]string{"data", "data20", "data3"},
			[]string{"data", "data3", "data20"},
		},
		{
			[]string{"1", "2", "30", "22", "0", "00", "3"},
			[]string{"0", "00", "1", "2", "3", "22", "30"},
		},
		{
			[]string{"A1", "A0", "A21", "A11", "A111", "A2"},
			[]string{"A0", "A1", "A2", "A11", "A21", "A111"},
		},
		{
			[]string{"A1BA1", "A11AA1", "A2AB0", "B1AA1", "A1AA1"},
			[]string{"A1AA1", "A1BA1", "A2AB0", "A11AA1", "B1AA1"},
		},
		{
			[]string{"1ax10", "1a10", "1ax2", "1ax"},
			[]string{"1a10", "1ax", "1ax2", "1ax10"},
		},
		{
			[]string{"z1a10", "z1ax2", "z1ax"},
			[]string{"z1a10", "z1ax", "z1ax2"},
		},
		{
			// regression test for #8
			[]string{"a0000001", "a0001"},
			[]string{"a0001", "a0000001"},
		},
		{
			// regression test for #10 - Number sort before any symbols even if theyre lower on the ASCII table
			[]string{"#1", "1", "_1", "a"},
			[]string{"1", "#1", "_1", "a"},
		},
		{
			// regression test for #10 - Number sort before any symbols even if theyre lower on the ASCII table
			[]string{"#1", "1", "_1", "a"},
			[]string{"1", "#1", "_1", "a"},
		},
		{	// test correct handling of space-only strings 
			[]string{"1", " ", "0"},
			[]string{"0", "1", " "},
		},
		{  // test correct handling of multiple spaces being correctly ordered AFTER numbers 
			[]string{"1", " ", " 1", "  "},
			[]string{"1", " ", " 1", "  "},
		},
		{
			[]string{"1", "#1", "a#", "a1"},
			[]string{"1", "#1", "a1", "a#"},
		},
		{
			// regression test for #10
			[]string{"111111111111111111112", "111111111111111111113", "1111111111111111111120"},
			[]string{"111111111111111111112", "111111111111111111113", "1111111111111111111120"},
		},
	}

	for i, c := range cases {
		sort.Sort(NaturalSort(c.data))
		if !reflect.DeepEqual(c.data, c.expected) {
			t.Fatalf("Wrong order in test case #%d.\nExpected=%v\nGot=%v", i, c.expected, c.data)
		}
	}

}

func BenchmarkSort(b *testing.B) {
	var data = [...]string{"A1BA1", "A11AA1", "A2AB0", "B1AA1", "A1AA1"}
	for ii := 0; ii < b.N; ii++ {
		d := NaturalSort(data[:])
		sort.Sort(d)
	}
}