-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
settings: support for supplying cmp.Option to some assertions (#92)
* settings: introduce concept of settings * settings: support for supplying cmp.Option settings * maps: bring back mapeq func * settings: rename files * readme: update readme with options * docs: add doc strings for settings
- Loading branch information
Showing
23 changed files
with
1,009 additions
and
733 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
// Package test provides a modern generic testing assertions library. | ||
package test | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/shoenig/test/internal/assertions" | ||
) | ||
|
||
// T is the minimal set of functions to be implemented by any testing framework | ||
// compatible with the test package. | ||
type T interface { | ||
Helper() | ||
Errorf(string, ...any) | ||
} | ||
|
||
func passing(result string) bool { | ||
return result == "" | ||
} | ||
|
||
func fail(t T, msg string, scripts ...PostScript) { | ||
c := assertions.Caller() | ||
s := c + msg + "\n" + run(scripts...) | ||
t.Errorf("\n" + strings.TrimSpace(s) + "\n") | ||
} | ||
|
||
func invoke(t T, result string, scripts ...PostScript) { | ||
result = strings.TrimSpace(result) | ||
if !passing(result) { | ||
fail(t, result, scripts...) | ||
} | ||
func errorf(t T, msg string, args ...any) { | ||
t.Errorf(msg, args...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.