Debian Codegraph @

stress/v2/statement/template_test.go

raw symbols SCIP
1 package statement
2
3 import (
4 "testing"
5 )
6
7 func TestNewTagFunc(t *testing.T) {
8 wtags := newTestTagsTemplate()
9 wfunc := newTestFunctionTemplate()
10
11 expected := wtags.Tags[0]
12 got := wtags.NewTagFunc()()
13 if got != expected {
14 t.Errorf("expected: %v\ngot: %v\n", expected, got)
15 }
16 expected = "EMPTY TAGS"
17 got = wfunc.NewTagFunc()()
18 if got != expected {
19 t.Errorf("expected: %v\ngot: %v\n", expected, got)
20 }
21 }
22
23 func TestNumSeries(t *testing.T) {
24 wtags := newTestTagsTemplate()
25 wfunc := newTestFunctionTemplate()
26
27 expected := len(wtags.Tags)
28 got := wtags.numSeries()
29 if got != expected {
30 t.Errorf("expected: %v\ngot: %v\n", expected, got)
31 }
32 expected = wfunc.Function.Count
33 got = wfunc.numSeries()
34 if got != expected {
35 t.Errorf("expected: %v\ngot: %v\n", expected, got)
36 }
37 }
38
39 func TestTemplatesInit(t *testing.T) {
40 tmpls := newTestTemplates()
41 s := tmpls.Init(5)
42 vals := s.Eval(spoofTime)
43 expected := tmpls[0].Tags[0]
44 got := vals[0]
45 if got != expected {
46 t.Errorf("expected: %v\ngot: %v\n", expected, got)
47 }
48 expected = "0i"
49 got = vals[1]
50 if got != expected {
51 t.Errorf("expected: %v\ngot: %v\n", expected, got)
52 }
53 }
54
55 func newTestTemplates() Templates {
56 return []*Template{
57 newTestTagsTemplate(),
58 newTestFunctionTemplate(),
59 }
60 }
61
62 func newTestTagsTemplate() *Template {
63 return &Template{
64 Tags: []string{"thing", "other_thing"},
65 }
66 }
67
68 func newTestFunctionTemplate() *Template {
69 return &Template{
70 Function: newIntIncFunction(),
71 }
72 }