feat: add tests for assert package
This commit is contained in:
107
assert/assert_test.go
Normal file
107
assert/assert_test.go
Normal file
@@ -0,0 +1,107 @@
|
||||
package Assert
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
Testing "github.com/lbatuska/goutils/testing"
|
||||
)
|
||||
|
||||
func Test_notNil(t *testing.T) {
|
||||
var something *interface{}
|
||||
Testing.AssertPanic(t, func() {
|
||||
NotNil(something)
|
||||
})
|
||||
|
||||
somethingElse := make([]int, 5)
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
NotNil(&somethingElse)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_nil(t *testing.T) {
|
||||
var something *interface{}
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
Nil(something)
|
||||
})
|
||||
|
||||
somethingElse := make([]int, 5)
|
||||
Testing.AssertPanic(t, func() {
|
||||
Nil(&somethingElse)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_assert(t *testing.T) {
|
||||
something := false
|
||||
Testing.AssertPanic(t, func() {
|
||||
Assert(something)
|
||||
})
|
||||
|
||||
somethingElse := true
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
Assert(somethingElse)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_true(t *testing.T) {
|
||||
something := false
|
||||
Testing.AssertPanic(t, func() {
|
||||
True(something)
|
||||
})
|
||||
|
||||
somethingElse := true
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
True(somethingElse)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_assertNot(t *testing.T) {
|
||||
something := false
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
AssertNot(something)
|
||||
})
|
||||
|
||||
somethingElse := true
|
||||
Testing.AssertPanic(t, func() {
|
||||
AssertNot(somethingElse)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_false(t *testing.T) {
|
||||
something := false
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
False(something)
|
||||
})
|
||||
|
||||
somethingElse := true
|
||||
Testing.AssertPanic(t, func() {
|
||||
False(somethingElse)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_equal(t *testing.T) {
|
||||
something := "this is something"
|
||||
something2 := "this is something"
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
Equal(something, something2)
|
||||
})
|
||||
|
||||
somethingElse := "this is something else"
|
||||
somethingElse2 := "this is something completely else"
|
||||
Testing.AssertPanic(t, func() {
|
||||
Equal(somethingElse, somethingElse2)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_notEqual(t *testing.T) {
|
||||
something := "this is something"
|
||||
something2 := "this is something"
|
||||
Testing.AssertPanic(t, func() {
|
||||
NotEqual(something, something2)
|
||||
})
|
||||
|
||||
somethingElse := "this is something else"
|
||||
somethingElse2 := "this is something completely else"
|
||||
Testing.AssertNotPanic(t, func() {
|
||||
NotEqual(somethingElse, somethingElse2)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user