more tests and fixed a bug the tests found. Cleaned up the documentation. Renamed Backups to MaxBackups.
This commit is contained in:
@@ -8,10 +8,14 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// assert will log the given message if condition is false.
|
||||
func assert(condition bool, t testing.TB, msg string, v ...interface{}) {
|
||||
assertUp(condition, t, 1, msg, v...)
|
||||
}
|
||||
|
||||
// assertUp is like assert, but used inside helper functions, to ensure that
|
||||
// the file and line number reported by failures corresponds to one or more
|
||||
// levels up the stack.
|
||||
func assertUp(condition bool, t testing.TB, caller int, msg string, v ...interface{}) {
|
||||
if !condition {
|
||||
_, file, line, _ := runtime.Caller(caller + 1)
|
||||
@@ -21,10 +25,14 @@ func assertUp(condition bool, t testing.TB, caller int, msg string, v ...interfa
|
||||
}
|
||||
}
|
||||
|
||||
// equals tests that the two values are equal according to reflect.DeepEqual.
|
||||
func equals(exp, act interface{}, t testing.TB) {
|
||||
equalsUp(exp, act, t, 1)
|
||||
}
|
||||
|
||||
// equalsUp is like equals, but used inside helper functions, to ensure that the
|
||||
// file and line number reported by failures corresponds to one or more levels
|
||||
// up the stack.
|
||||
func equalsUp(exp, act interface{}, t testing.TB, caller int) {
|
||||
if !reflect.DeepEqual(exp, act) {
|
||||
_, file, line, _ := runtime.Caller(caller + 1)
|
||||
@@ -34,10 +42,15 @@ func equalsUp(exp, act interface{}, t testing.TB, caller int) {
|
||||
}
|
||||
}
|
||||
|
||||
// isNil reports a failure if the given value is not nil. Note that values
|
||||
// which cannot be nil will always fail this check.
|
||||
func isNil(obtained interface{}, t testing.TB) {
|
||||
isNilUp(obtained, t, 1)
|
||||
}
|
||||
|
||||
// isNilUp is like isNil, but used inside helper functions, to ensure that the
|
||||
// file and line number reported by failures corresponds to one or more levels
|
||||
// up the stack.
|
||||
func isNilUp(obtained interface{}, t testing.TB, caller int) {
|
||||
if !_isNil(obtained) {
|
||||
_, file, line, _ := runtime.Caller(caller + 1)
|
||||
@@ -46,10 +59,14 @@ func isNilUp(obtained interface{}, t testing.TB, caller int) {
|
||||
}
|
||||
}
|
||||
|
||||
// notNil reports a failure if the given value is nil.
|
||||
func notNil(obtained interface{}, t testing.TB) {
|
||||
notNilUp(obtained, t, 1)
|
||||
}
|
||||
|
||||
// notNilUp is like notNil, but used inside helper functions, to ensure that the
|
||||
// file and line number reported by failures corresponds to one or more levels
|
||||
// up the stack.
|
||||
func notNilUp(obtained interface{}, t testing.TB, caller int) {
|
||||
if _isNil(obtained) {
|
||||
_, file, line, _ := runtime.Caller(caller + 1)
|
||||
@@ -58,6 +75,8 @@ func notNilUp(obtained interface{}, t testing.TB, caller int) {
|
||||
}
|
||||
}
|
||||
|
||||
// _isNil is a helper function for isNil and notNil, and should not be used
|
||||
// directly.
|
||||
func _isNil(obtained interface{}) bool {
|
||||
if obtained == nil {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user