This file is indexed.

/usr/share/gocode/src/github.com/goji/param/crazy_test.go is in golang-github-goji-param-dev 0.0~git20160927.d7f49fd-4.

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
package param

import (
	"net/url"
	"testing"
)

type Crazy struct {
	A     *Crazy
	B     *Crazy
	Value int
	Slice []int
	Map   map[string]Crazy
}

func TestCrazy(t *testing.T) {
	t.Parallel()

	c := Crazy{}
	err := Parse(url.Values{
		"A[B][B][A][Value]":       {"1"},
		"B[A][A][Slice][]":        {"3", "1", "4"},
		"B[Map][hello][A][Value]": {"8"},
		"A[Value]":                {"2"},
		"A[Slice][]":              {"9", "1", "1"},
		"Value":                   {"42"},
	}, &c)
	if err != nil {
		t.Error("Error parsing craziness: ", err)
	}

	// Exhaustively checking everything here is going to be a huge pain, so
	// let's just hope for the best, pretend NPEs don't exist, and hope that
	// this test covers enough stuff that it's actually useful.
	assertEqual(t, "c.A.B.B.A.Value", 1, c.A.B.B.A.Value)
	assertEqual(t, "c.A.Value", 2, c.A.Value)
	assertEqual(t, "c.Value", 42, c.Value)
	assertEqual(t, `c.B.Map["hello"].A.Value`, 8, c.B.Map["hello"].A.Value)

	assertEqual(t, "c.A.B.B.B", (*Crazy)(nil), c.A.B.B.B)
	assertEqual(t, "c.A.B.A", (*Crazy)(nil), c.A.B.A)
	assertEqual(t, "c.A.A", (*Crazy)(nil), c.A.A)

	if c.Slice != nil || c.Map != nil {
		t.Error("Map and Slice should not be set")
	}

	sl := c.B.A.A.Slice
	if len(sl) != 3 || sl[0] != 3 || sl[1] != 1 || sl[2] != 4 {
		t.Error("Something is wrong with c.B.A.A.Slice")
	}
	sl = c.A.Slice
	if len(sl) != 3 || sl[0] != 9 || sl[1] != 1 || sl[2] != 1 {
		t.Error("Something is wrong with c.A.Slice")
	}
}