assert type equality?
geddski opened this issue · 2 comments
total golang noob here. How do you compare type equality w goblin?
var i int = 42
var f float64 = float64(i)
g.Assert(reflect.ValueOf(f).Kind()).Equal("float64")
// FAILS with "float64 does not equal float64"
Hi Dave,
Here's an example to achieve what you're trying to do:
package test
import (
. "github.com/franela/goblin"
"testing"
"reflect"
)
func TestType(t *testing.T) {
g:= Goblin(t)
g.Describe("Types", func(){
g.It("Should be equal ", func(){
var i int = 42
var f float64 = float64(i)
g.Assert(reflect.ValueOf(f).Kind()).Equal(reflect.Float64)
})
})
}
Best,
Marcos.
On Sat, Mar 29, 2014 at 8:31 PM, Dave Geddes notifications@github.comwrote:
total golang noob here. How do you compare type equality w goblin?
var i int = 42var f float64 = float64(i)g.Assert(reflect.ValueOf(f).Kind()).Equal("float64")// FAILS with "float64 does not equal float64"
Reply to this email directly or view it on GitHubhttps://github.com//issues/40
.
Beauty, thank you! Hopefully I'll grok that once I've learned more.
On Mar 29, 2014 9:53 PM, "Marcos Nils" notifications@github.com wrote:
Hi Dave,
Here's an example to achieve what you're trying to do:
package test
import (
. "github.com/franela/goblin"
"testing"
"reflect"
)
func TestType(t *testing.T) {
g:= Goblin(t)
g.Describe("Types", func(){
g.It("Should be equal ", func(){
var i int = 42
var f float64 = float64(i)
g.Assert(reflect.ValueOf(f).Kind()).Equal(reflect.Float64)
})
})
}
Best,
Marcos.
On Sat, Mar 29, 2014 at 8:31 PM, Dave Geddes <notifications@github.com
wrote:
total golang noob here. How do you compare type equality w goblin?
var i int = 42var f float64 =
float64(i)g.Assert(reflect.ValueOf(f).Kind()).Equal("float64")// FAILS with
"float64 does not equal float64"Reply to this email directly or view it on GitHub<
https://github.com/franela/goblin/issues/40>
.Reply to this email directly or view it on GitHubhttps://github.com//issues/40#issuecomment-39016894
.