Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Log seed to replicate error * Remove dependecy to testify Fixes: #189 * Remove duplicated test `TestParallel` duplicates `TestCacheDelRandomly`.
- Loading branch information
1 parent
4d58a32
commit b7689f7
Showing
7 changed files
with
258 additions
and
214 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package bigcache | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"path" | ||
"reflect" | ||
"runtime" | ||
"testing" | ||
) | ||
|
||
func assertEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) { | ||
if !objectsAreEqual(expected, actual) { | ||
_, file, line, _ := runtime.Caller(1) | ||
file = path.Base(file) | ||
t.Errorf(fmt.Sprintf("\n%s:%d: Not equal: \n"+ | ||
"expected: %T(%#v)\n"+ | ||
"actual : %T(%#v)\n", | ||
file, line, expected, expected, actual, actual), msgAndArgs...) | ||
} | ||
} | ||
|
||
func noError(t *testing.T, e error) { | ||
if e != nil { | ||
_, file, line, _ := runtime.Caller(1) | ||
file = path.Base(file) | ||
t.Errorf(fmt.Sprintf("\n%s:%d: Error is not nil: \n"+ | ||
"actual : %T(%#v)\n", file, line, e, e)) | ||
} | ||
} | ||
|
||
func objectsAreEqual(expected, actual interface{}) bool { | ||
if expected == nil || actual == nil { | ||
return expected == actual | ||
} | ||
|
||
exp, ok := expected.([]byte) | ||
if !ok { | ||
return reflect.DeepEqual(expected, actual) | ||
} | ||
|
||
act, ok := actual.([]byte) | ||
if !ok { | ||
return false | ||
} | ||
if exp == nil || act == nil { | ||
return exp == nil && act == nil | ||
} | ||
return bytes.Equal(exp, act) | ||
} |
Oops, something went wrong.