byteSliceEq
parent
0698d68032
commit
4eda8330e8
|
@ -15,6 +15,8 @@
|
||||||
package flushfs_test
|
package flushfs_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -76,7 +78,24 @@ func (t *FlushFSTest) SetUp(ti *TestInfo) {
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Match byte slices equal to the supplied string.
|
// Match byte slices equal to the supplied string.
|
||||||
func byteSliceEq(expected string) Matcher
|
func byteSliceEq(expected string) Matcher {
|
||||||
|
pred := func(c interface{}) error {
|
||||||
|
slice, ok := c.([]byte)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("which is not []byte")
|
||||||
|
}
|
||||||
|
|
||||||
|
if string(slice) != expected {
|
||||||
|
return fmt.Errorf("which is string \"%s\"", string(slice))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewMatcher(
|
||||||
|
pred,
|
||||||
|
fmt.Sprintf("byte slice equal to string \"%s\"", expected))
|
||||||
|
}
|
||||||
|
|
||||||
// Return a copy of the current contents of t.flushes.
|
// Return a copy of the current contents of t.flushes.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue