-
Notifications
You must be signed in to change notification settings - Fork 5
/
failure_test.go
56 lines (50 loc) · 1.35 KB
/
failure_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
package assertly
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestFailure_Index(t *testing.T) {
{
var failure = NewFailure("", "[/]:ad[12].we", "", nil, nil)
assert.EqualValues(t, 12, failure.Index())
}
{
var failure = NewFailure("", "ad[12].we", "", nil, nil)
assert.EqualValues(t, -1, failure.Index())
}
{
var failure = NewFailure("", ":ad[a].we", "", nil, nil)
assert.EqualValues(t, -1, failure.Index())
}
{
var failure = NewFailure("", ":ad[].we", "", nil, nil)
assert.EqualValues(t, -1, failure.Index())
}
}
func TestFailure_LeafKey(t *testing.T) {
{
var failure = NewFailure("", "[/]:ad[12].we", "", nil, nil)
assert.EqualValues(t, "we", failure.LeafKey())
}
{
var failure = NewFailure("", "[/]:ad[12].", "", nil, nil)
assert.EqualValues(t, "", failure.LeafKey())
}
{
var failure = NewFailure("", "[/]:ad[12]", "", nil, nil)
assert.EqualValues(t, "", failure.LeafKey())
}
}
func TestFailure_MergeFrom(t *testing.T) {
var failure = NewFailure("", "[/]:ad[12].we", "", nil, nil)
source := NewValidation()
source.PassedCount = 2
source.AddFailure(failure)
target := NewValidation()
target.AddFailure(failure)
target.PassedCount = 2
target.MergeFrom(source)
assert.EqualValues(t, 4, target.PassedCount)
assert.EqualValues(t, 2, target.FailedCount)
assert.EqualValues(t, 2, len(target.Failures))
}