From b24ece723d913e44104fbf574822bf1d595d6c9b Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Sat, 31 Aug 2019 12:51:48 -0600 Subject: [PATCH] Created AccessKeyCode type --- attribute/accesskey.go | 8 +++++++- attribute/accesskey_test.go | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 attribute/accesskey_test.go diff --git a/attribute/accesskey.go b/attribute/accesskey.go index a1bcede..b593de1 100644 --- a/attribute/accesskey.go +++ b/attribute/accesskey.go @@ -2,9 +2,15 @@ package attribute import "gitlab.codemonkeysoftware.net/b/hatmill" +type AccessKeyCode rune + +func (c AccessKeyCode) String() string { + return string([]rune{rune(c)}) +} + func Accesskey(value rune) hatmill.Attrib { return hatmill.Attrib{ Key: "accesskey", - Value: String([]rune{value}), + Value: AccessKeyCode(value), } } diff --git a/attribute/accesskey_test.go b/attribute/accesskey_test.go new file mode 100644 index 0000000..16404bb --- /dev/null +++ b/attribute/accesskey_test.go @@ -0,0 +1,12 @@ +package attribute_test + +import ( + "gitlab.codemonkeysoftware.net/b/hatmill/attribute" + "testing" +) + +func TestAccessKeyString(t *testing.T) { + actual := attribute.AccessKeyCode('a').String() + expected := "a" + expectEqualStrings(t, actual, expected) +}