Skip to content

Commit

Permalink
Merge pull request #167 from dolmen-go/more-CRun-coverage-check-Format
Browse files Browse the repository at this point in the history
Add test for C.Run for more coverage
  • Loading branch information
frankban authored Mar 1, 2024
2 parents b4e45aa + 789d923 commit e80fb90
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions quicktest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,27 @@ want:
`)
}

func TestCRunFormatWithC(t *testing.T) {
tt, innerTT := &testingT{}, &testingT{}
// Wrap the C with another C so the C.Run has to call a Run(string, func(*C) bool) instead of Run(string, func(*testing.T) bool)
c := qt.New(qt.New(tt))
c.SetFormat(func(v interface{}) string {
return fmt.Sprintf("myfmt(%v)", v)
})
c.Run("my test", func(innerC *qt.C) {
innerC.TB = innerTT
innerC.Check(42, qt.Equals, nil)
})
assertPrefix(t, innerTT.errorString(), `
error:
values are not equal
got:
myfmt(42)
want:
myfmt(<nil>)
`)
}

func TestHelper(t *testing.T) {
tt := &testingT{}
qt.Assert(tt, true, qt.IsFalse)
Expand Down

0 comments on commit e80fb90

Please sign in to comment.