hatmill/attribute/coords_test.go

41 lines
1.3 KiB
Go
Raw Normal View History

2019-05-30 04:41:04 +00:00
package attribute_test
import (
"testing"
"gitlab.codemonkeysoftware.net/b/hatmill/attribute"
)
func TestCoordsNumberFormat(t *testing.T) {
for _, testcase := range []struct {
name string
f float32
value string
}{
{name: "zero", f: 0, value: "0"},
{name: "integral", f: 45, value: "45"},
{name: "positive fractional, small positive exponent", f: 12.55, value: "12.55"},
{name: "positive fractional, large positive exponent", f: 1.55E+12, value: "1.55E+12"},
{name: "positive fractional, large negative exponent", f: 1.55E-12, value: "1.55E-12"},
{name: "negative fractional, small positive exponent", f: -12.55, value: "-12.55"},
{name: "negative fractional, large positive exponent", f: -1.55E+12, value: "-1.55E+12"},
{name: "negative fractional, large negative exponent", f: -1.55E-12, value: "-1.55E-12"},
} {
t.Run(testcase.name, func(t *testing.T) {
testAttribValue(t, attribute.Coords(testcase.f), testcase.value)
})
}
}
func TestCoordsCardinality(t *testing.T) {
t.Run("zero", func(t *testing.T) {
testAttribValue(t, attribute.Coords(), "")
})
t.Run("one", func(t *testing.T) {
testAttribValue(t, attribute.Coords(5), "5")
})
t.Run("many", func(t *testing.T) {
testAttribValue(t, attribute.Coords(5, 4, 3, 2, 1), "5,4,3,2,1")
})
}