Remove unused util functions

This commit is contained in:
Adrian Zankich 2014-06-15 17:32:19 -07:00
parent 4d122c0540
commit c56f285abb
2 changed files with 0 additions and 31 deletions

View File

@ -3,7 +3,6 @@ package gobot
import (
"math"
"math/rand"
"reflect"
"time"
)
@ -40,21 +39,6 @@ func Rand(max int) int {
return r.Intn(max)
}
func Call(thing interface{}, method string, params ...interface{}) []reflect.Value {
in := make([]reflect.Value, len(params))
for k, param := range params {
in[k] = reflect.ValueOf(param)
}
return reflect.ValueOf(thing).MethodByName(method).Call(in)
}
func FieldByName(thing interface{}, field string) reflect.Value {
return reflect.ValueOf(thing).FieldByName(field)
}
func FieldByNamePtr(thing interface{}, field string) reflect.Value {
return reflect.ValueOf(thing).Elem().FieldByName(field)
}
func FromScale(input, min, max float64) float64 {
return (input - math.Min(min, max)) / (math.Max(min, max) - math.Min(min, max))
}

View File

@ -62,18 +62,3 @@ func TestRand(t *testing.T) {
t.Error(fmt.Sprintf("%v should not equal %v", a, b))
}
}
func TestFieldByName(t *testing.T) {
testInterface := *NewTestStruct()
Expect(t, FieldByName(testInterface, "i").Int(), int64(10))
}
func TestFieldByNamePtr(t *testing.T) {
testInterface := NewTestStruct()
Expect(t, FieldByNamePtr(testInterface, "f").Float(), 0.2)
}
func TestCall(t *testing.T) {
testInterface := NewTestStruct()
Expect(t, Call(testInterface, "Hello", "Human", "How are you?")[0].String(), "Hello Human! How are you?")
}