-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathif_test.go
43 lines (34 loc) · 801 Bytes
/
if_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
package examples_test
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/testcase/assert"
)
func IfSubject(condition bool) string {
if condition {
return `A`
} else {
return `B`
}
}
func TestIfSubject(t *testing.T) {
s := testcase.NewSpec(t)
var (
condition = testcase.Var[bool]{ID: `condition`}
subject = func(t *testcase.T) string {
return IfSubject(condition.Get(t))
}
)
s.When(`condition described`, func(s *testcase.Spec) {
condition.LetValue(s, true)
s.Then(`it will return ...`, func(t *testcase.T) {
assert.Must(t).Equal(`A`, subject(t))
})
})
s.When(`condition opposite described`, func(s *testcase.Spec) {
condition.LetValue(s, false)
s.Then(`it will return ...`, func(t *testcase.T) {
assert.Must(t).Equal(`B`, subject(t))
})
})
}