-
Notifications
You must be signed in to change notification settings - Fork 2
/
counter_test.go
87 lines (78 loc) · 1.67 KB
/
counter_test.go
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
package specfile
import (
"testing"
)
func TestValidCounter(t *testing.T) {
var c Counter
c.NextLineConcats = 1
c.CurlyBrackets = 1
c.SquareBrackets = 1
c.Parentheses = 1
if c.Valid() == true {
t.Error("[counter]Valid test failed")
}
}
func TestValidCounterWithOptions(t *testing.T) {
var c Counter
c.Parentheses = 1
if c.Valid("Parentheses") == false {
t.Error("[counter]Valid with options test failed")
}
}
func TestResetCounter(t *testing.T) {
var c Counter
c.NextLineConcats = 1
(&c).Reset()
if c.NextLineConcats != 0 {
t.Error("[counter]Reset test failed")
}
}
func TestCountNextLineConcats(t *testing.T) {
var c Counter
str := RandStringBytes(10)
str += "\\"
(&c).Count([]byte(str))
if c.NextLineConcats != 1 {
t.Error("[counter]Count NextLine Concats failed")
}
}
func TestCountNextLineConcatsInTheMiddle(t *testing.T) {
var c Counter
str := RandStringBytes(10)
str += "\\"
str += RandStringBytes(10)
(&c).Count([]byte(str))
if c.NextLineConcats != 0 {
t.Error("[counter]Count NextLine Concats failed")
}
}
func TestCountCurlyBrackets(t *testing.T) {
var c Counter
str := "{"
str += RandStringBytes(10)
str += "}"
(&c).Count([]byte(str))
if c.CurlyBrackets != 0 {
t.Error("[counter]Count Curly Brackets failed")
}
}
func TestCountSquareBrackets(t *testing.T) {
var c Counter
str := "["
str += RandStringBytes(10)
str += "]"
(&c).Count([]byte(str))
if c.SquareBrackets != 0 {
t.Error("[counter]Count Square Brackets failed")
}
}
func TestCountParentheses(t *testing.T) {
var c Counter
str := "("
str += RandStringBytes(10)
str += ")"
(&c).Count([]byte(str))
if c.Parentheses != 0 {
t.Error("[counter]Count Parentheses failed")
}
}