mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
acf2f13dcb
* sync with MontFerret/ferret * fix --param handling When params is converted to map it uses strings.Split, which slices a string into all substrings separated by :. * remove impossible conditions nil != nil * delete ineffectual assignments * replace '+= 1' with '++' * remove useless comparison with nil * merge variable declarations * remove bool comparison * fix imports * fix imports * delete unused file * use copy instead of loop * delete unused DummyInterface * remove unnecassary break statements * tidy modules
65 lines
911 B
Go
65 lines
911 B
Go
package core_test
|
|
|
|
import (
|
|
"testing"
|
|
"unsafe"
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
type DummyStruct struct{}
|
|
|
|
func TestIsNil(t *testing.T) {
|
|
Convey("Should match", t, func() {
|
|
// nil == invalid
|
|
t := core.IsNil(nil)
|
|
|
|
So(t, ShouldBeTrue)
|
|
|
|
a := []string{}
|
|
t = core.IsNil(a)
|
|
|
|
So(t, ShouldBeFalse)
|
|
|
|
b := make([]string, 1)
|
|
t = core.IsNil(b)
|
|
|
|
So(t, ShouldBeFalse)
|
|
|
|
c := make(map[string]string)
|
|
t = core.IsNil(c)
|
|
|
|
So(t, ShouldBeFalse)
|
|
|
|
var s struct {
|
|
Test string
|
|
}
|
|
t = core.IsNil(s)
|
|
|
|
So(t, ShouldBeFalse)
|
|
|
|
f := func() {}
|
|
t = core.IsNil(f)
|
|
|
|
So(t, ShouldBeFalse)
|
|
|
|
i := DummyStruct{}
|
|
t = core.IsNil(i)
|
|
|
|
So(t, ShouldBeFalse)
|
|
|
|
ch := make(chan string)
|
|
t = core.IsNil(ch)
|
|
|
|
So(t, ShouldBeFalse)
|
|
|
|
var y unsafe.Pointer
|
|
var vy int
|
|
y = unsafe.Pointer(&vy)
|
|
t = core.IsNil(y)
|
|
|
|
So(t, ShouldBeFalse)
|
|
})
|
|
}
|