mirror of
https://github.com/kidoman/embd
synced 2024-12-22 04:40:04 +01:00
add test for Map
This commit is contained in:
parent
faa18255bd
commit
624ce1bb16
29
util/map_test.go
Normal file
29
util/map_test.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package util
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestMap(t *testing.T) {
|
||||||
|
var tests = []struct {
|
||||||
|
x, inmin, inmax, outmin, outmax int64
|
||||||
|
val int64
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
90, 0, 180, 1000, 2000,
|
||||||
|
1500,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
10, 10, 15, 10, 20,
|
||||||
|
10,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
15, 10, 15, 10, 20,
|
||||||
|
20,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
val := Map(test.x, test.inmin, test.inmax, test.outmin, test.outmax)
|
||||||
|
if val != test.val {
|
||||||
|
t.Errorf("Map of %v from (%v -> %v) to (%v -> %v): got %v, want %v", test.x, test.inmin, test.inmax, test.outmin, test.outmax, val, test.val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user