This file is indexed.

/usr/share/gocode/src/github.com/paulbellamy/ratecounter/counter_test.go is in golang-github-paulbellamy-ratecounter-dev 0.2.0-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
package ratecounter

import (
	"sync"
	"testing"
)

func TestCounter(t *testing.T) {
	var c Counter

	check := func(expected int64) {
		val := c.Value()
		if val != expected {
			t.Error("Expected ", val, " to equal ", expected)
		}
	}

	check(0)
	c.Incr(1)
	check(1)
	c.Incr(9)
	check(10)

	// Concurrent usage
	wg := &sync.WaitGroup{}
	wg.Add(3)
	for i := 1; i <= 3; i++ {
		go func(val int64) {
			c.Incr(val)
			wg.Done()
		}(int64(i))
	}
	wg.Wait()
	check(16)
}

func BenchmarkCounter(b *testing.B) {
	var c Counter

	for i := 0; i < b.N; i++ {
		c.Incr(1)
	}
}