Skip to content

Commit

Permalink
Remove dependecy to testify (#190)
Browse files Browse the repository at this point in the history
* Log seed to replicate error

* Remove dependecy to testify

Fixes: #189

* Remove duplicated test

`TestParallel` duplicates `TestCacheDelRandomly`.
  • Loading branch information
janisz authored and cristaloleg committed Dec 3, 2019
1 parent 4d58a32 commit b7689f7
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 214 deletions.
50 changes: 50 additions & 0 deletions assert_test.go
@@ -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)
}

0 comments on commit b7689f7

Please sign in to comment.