cast/cast_test.go

27 lines
673 B
Go
Raw Normal View History

2014-04-05 09:21:52 +04:00
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestToInt(t *testing.T) {
var eight interface{} = 8
assert.Equal(t, ToInt(8), 8)
assert.Equal(t, ToInt("8"), 8)
assert.Equal(t, ToInt(true), 1)
assert.Equal(t, ToInt(false), 0)
assert.Equal(t, ToInt(eight), 8)
}
func TestMaps(t *testing.T) {
var taxonomies = map[interface{}]interface{}{"tag": "tags", "group": "groups"}
assert.Equal(t, ToStringMap(taxonomies), map[string]interface{}{"tag": "tags", "group": "groups"})
}