forked from gucumber/gucumber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes_test.go
80 lines (67 loc) · 1.93 KB
/
types_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
package gherkin
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStringDataToTable(t *testing.T) {
s := StringData("| a | b |\n| 1 | 2 |\n| 3 | 4 |")
tab := TabularData{
[]string{"a", "b"},
[]string{"1", "2"},
[]string{"3", "4"},
}
assert.Equal(t, tab, s.ToTable())
}
func TestTabularDataToMap(t *testing.T) {
tab := TabularData{
[]string{"a", "b", "c", "d"},
[]string{"1", "2", "3", "4"},
[]string{"5", "6", "7", "8"},
[]string{"9", "A", "B", "C"},
}
m := TabularDataMap{
"a": []string{"1", "5", "9"},
"b": []string{"2", "6", "A"},
"c": []string{"3", "7", "B"},
"d": []string{"4", "8", "C"},
}
assert.Equal(t, m, tab.ToMap())
assert.Equal(t, 3, m.NumRows())
}
func TestTabularDataMapEmpty(t *testing.T) {
var tab TabularData
var m TabularDataMap
// only headers
tab = TabularData{[]string{"a", "b", "c", "d"}}
m = TabularDataMap{}
assert.Equal(t, m, tab.ToMap())
assert.Equal(t, 0, m.NumRows())
// completely empty
tab = TabularData{}
m = TabularDataMap{}
assert.Equal(t, m, tab.ToMap())
assert.Equal(t, 0, m.NumRows())
}
func TestScenarioFilters(t *testing.T) {
f := &Feature{Tags: []string{}}
s := Scenario{Tags: []string{"@a", "@b"}}
assert.True(t, s.FilterMatched(f))
assert.False(t, s.FilterMatched(f, "a"))
assert.True(t, s.FilterMatched(f, "@a"))
assert.True(t, s.FilterMatched(f, "@c", "@a"))
assert.False(t, s.FilterMatched(f, "~@a"))
assert.False(t, s.FilterMatched(f, "@a,@c"))
assert.True(t, s.FilterMatched(f, "@a,@b", "@c"))
s = Scenario{Tags: []string{}}
assert.False(t, s.FilterMatched(f, "@a"))
}
func TestFeatureFilters(t *testing.T) {
s := Feature{Tags: []string{"@a", "@b"}}
assert.True(t, s.FilterMatched())
assert.False(t, s.FilterMatched("a"))
assert.True(t, s.FilterMatched("@a"))
assert.True(t, s.FilterMatched("@c", "@a"))
assert.False(t, s.FilterMatched("~@a"))
assert.False(t, s.FilterMatched("@a,@c"))
assert.True(t, s.FilterMatched("@a,@b", "@c"))
}