hatmill/attribute/generated_test.go

46 lines
1.1 KiB
Go
Raw Normal View History

2019-05-30 03:33:30 +00:00
package attribute_test
import (
2019-05-30 03:42:48 +00:00
"testing"
2019-05-30 03:33:30 +00:00
2019-05-30 03:42:48 +00:00
"gitlab.codemonkeysoftware.net/b/hatmill"
"gitlab.codemonkeysoftware.net/b/hatmill/attribute"
2019-05-30 03:33:30 +00:00
)
func testAttribValue(t *testing.T, attrib hatmill.Attrib, expectedValue string) {
2019-05-30 03:42:48 +00:00
t.Helper()
if attrib.ValueString() != expectedValue {
t.Fatalf("expected attribute value to be %#v, but got %#v", expectedValue, attrib.ValueString())
2019-05-30 03:42:48 +00:00
}
2019-05-30 03:33:30 +00:00
}
func TestString(t *testing.T) {
2019-05-30 03:42:48 +00:00
const s = "abcdefg"
testAttribValue(t, attribute.Id(s), s)
2019-05-30 03:33:30 +00:00
}
func TestBool(t *testing.T) {
2019-05-30 03:42:48 +00:00
testAttribValue(t, attribute.Disabled(), "")
2019-05-30 03:33:30 +00:00
}
func TestExplicitBool(t *testing.T) {
2019-05-30 03:42:48 +00:00
t.Run("true", func(t *testing.T) {
testAttribValue(t, attribute.Draggable(true), "true")
})
t.Run("false", func(t *testing.T) {
testAttribValue(t, attribute.Draggable(false), "false")
})
2019-05-30 03:33:30 +00:00
}
func TestInt(t *testing.T) {
2019-05-30 03:42:48 +00:00
t.Run("zero", func(t *testing.T) {
testAttribValue(t, attribute.Height(0), "0")
})
t.Run("positive", func(t *testing.T) {
testAttribValue(t, attribute.Height(45), "45")
})
t.Run("negative", func(t *testing.T) {
testAttribValue(t, attribute.Tabindex(-45), "-45")
})
2019-05-30 03:33:30 +00:00
}