mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-05-10 09:24:07 -04:00
added ExpectImplements() function to test package
This commit is contained in:
parent
1a26231b5e
commit
08f105af6b
|
@ -47,7 +47,6 @@ type winSelectROM struct {
|
|||
|
||||
currPath string
|
||||
entries []os.DirEntry
|
||||
err error
|
||||
|
||||
selectedFile string
|
||||
selectedFileBase string
|
||||
|
|
|
@ -18,11 +18,14 @@
|
|||
//
|
||||
// The ExpectEquality() is the most basic and probably the most useful function.
|
||||
// It compares like-typed variables for equality and returns true if they match.
|
||||
// ExpectInequality() is the inverse function.
|
||||
//
|
||||
// The ExpectFailure() and ExpectSuccess() functions test for failure and
|
||||
// success. These two functions work with bool or error and special handling for
|
||||
// nil.
|
||||
//
|
||||
// ExpectImplements() tests whether an instance implements the specified type.
|
||||
//
|
||||
// The Writer type meanwhile, implements the io.Writer interface and should be
|
||||
// used to capture output. The Writer.Compare() function can then be used to
|
||||
// test for equality.
|
||||
|
|
|
@ -34,6 +34,14 @@ func ExpectInequality[T comparable](t *testing.T, value T, expectedValue T) {
|
|||
}
|
||||
}
|
||||
|
||||
// ExpectImplements tests whether an instance is an implementation of type T
|
||||
func ExpectImplements[T comparable](t *testing.T, instance any, implements T) {
|
||||
t.Helper()
|
||||
if _, ok := instance.(T); !ok {
|
||||
t.Fatalf("implementation test of type %T failed: type %T does not implement %T", instance, instance, implements)
|
||||
}
|
||||
}
|
||||
|
||||
// ExpectFailure tests argument v for a failure condition suitable for it's
|
||||
// type. Types bool and error are treated thus:
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue