Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
adamluzsi committed Jul 25, 2022
1 parent 0d2b8a9 commit b162518
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,23 @@ func (spec *Spec) Context(desc string, testContextBlock sBlock, opts ...SpecOpti
switch tb := spec.testingTB.(type) {
case tRunner:
tb.Run(name, func(t *testing.T) {
t.Helper()
sub.withFinishUsingTestingTB(t, func() {
testContextBlock(sub)
})
})

case bRunner:
tb.Run(name, func(b *testing.B) {
b.Helper()
sub.withFinishUsingTestingTB(b, func() {
testContextBlock(sub)
})
})

case TBRunner:
tb.Run(name, func(tb testing.TB) {
tb.Helper()
sub.withFinishUsingTestingTB(tb, func() {
testContextBlock(sub)
})
Expand Down Expand Up @@ -345,6 +348,9 @@ func (spec *Spec) run(blk func(*T)) {
switch tb := spec.testingTB.(type) {
case tRunner:
spec.addTest(func() {
if h, ok := tb.(helper); ok {
h.Helper()
}
tb.Run(name, func(t *testing.T) {
t.Helper()
spec.runTB(t, blk)
Expand All @@ -362,13 +368,19 @@ func (spec *Spec) run(blk func(*T)) {
})
case TBRunner:
spec.addTest(func() {
if h, ok := tb.(helper); ok {
h.Helper()
}
tb.Run(name, func(tb testing.TB) {
tb.Helper()
spec.runTB(tb, blk)
})
})
default:
spec.addTest(func() {
if h, ok := tb.(helper); ok {
h.Helper()
}
tb.Helper()
spec.runTB(tb, blk)
})
Expand Down
2 changes: 1 addition & 1 deletion random/random_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func SpecRandomMethods(s *testcase.Spec, rnd testcase.Var[*random.Random]) {

s.When("input slice has a length", func(s *testcase.Spec) {
length := testcase.Let(s, func(t *testcase.T) int {
return t.Random.IntN(42)
return t.Random.IntB(1, 42)
})
p.Let(s, func(t *testcase.T) []byte {
return make([]byte, length.Get(t))
Expand Down

0 comments on commit b162518

Please sign in to comment.