This file is indexed.

/usr/share/gocode/src/github.com/tendermint/go-wire/expr/expr_test.go is in golang-github-tendermint-go-wire-dev 0~20161027~0git287d8ca-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
package expr

import (
	"strings"
	"testing"

	. "github.com/tendermint/go-common"
)

func TestParse(t *testing.T) {
	testParse(t, `"foobar"`, `"foobar"`)
	testParse(t, "0x1234", "0x1234")
	testParse(t, "0xbeef", "0xBEEF")
	testParse(t, "xbeef", "xBEEF")
	testParse(t, "12345", "{i 12345}")
	testParse(t, "u64:12345", "{u64 12345}")
	testParse(t, "i64:12345", "{i64 12345}")
	testParse(t, "i64:-12345", "{i64 -12345}")
	testParse(t, "[1 u64:2]", "[{i 1},{u64 2}]")
	testParse(t, "[(1 2) (3 4)]", "[({i 1} {i 2}),({i 3} {i 4})]")
	testParse(t, "0x1234 1 u64:2 [3 4]", "(0x1234 {i 1} {u64 2} [{i 3},{i 4}])")
	testParse(t, "[(1 <sig:user1>)(2 <sig:user2>)][3 4]",
		"([({i 1} <sig:user1>),({i 2} <sig:user2>)] [{i 3},{i 4}])")
}

func testParse(t *testing.T, input string, expected string) {
	got, err := ParseReader(input, strings.NewReader(input))
	if err != nil {
		t.Error(err.Error())
		return
	}
	gotStr := Fmt("%v", got)
	if gotStr != expected {
		t.Error(Fmt("Expected %v, got %v", expected, gotStr))
	}
}

func TestBytes(t *testing.T) {
	testBytes(t, `"foobar"`, `0106666F6F626172`)
	testBytes(t, "0x1234", "01021234")
	testBytes(t, "0xbeef", "0102BEEF")
	testBytes(t, "xbeef", "BEEF")
	testBytes(t, "12345", "023039")
	testBytes(t, "u64:12345", "0000000000003039")
	testBytes(t, "i64:12345", "0000000000003039")
	testBytes(t, "i64:-12345", "FFFFFFFFFFFFCFC7")
	testBytes(t, "[1 u64:2]", "010201010000000000000002")
	testBytes(t, "[(1 2) (3 4)]", "01020101010201030104")
	testBytes(t, "0x1234 1 u64:2 [3 4]", "0102123401010000000000000002010201030104")
	testBytes(t, "[(1 <sig:user1>)(2 <sig:user2>)][3 4]",
		"0102010100010200010201030104")
}

func testBytes(t *testing.T, input string, expected string) {
	got, err := ParseReader(input, strings.NewReader(input))
	if err != nil {
		t.Error(err.Error())
		return
	}
	gotBytes, err := got.(Byteful).Bytes()
	if err != nil {
		t.Error(err.Error())
		return
	}
	gotHex := Fmt("%X", gotBytes)
	if gotHex != expected {
		t.Error(Fmt("Expected %v, got %v", expected, gotHex))
	}
}