36 lines
724 B
Go
36 lines
724 B
Go
package uiterm
|
|
|
|
import "testing"
|
|
|
|
func TestPrintableKeyTextRoundTrip(t *testing.T) {
|
|
encoded, err := KeyM.MarshalText()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(encoded) != "m" {
|
|
t.Fatalf("encoded key = %q, want m", encoded)
|
|
}
|
|
|
|
var decoded Key
|
|
if err := decoded.UnmarshalText([]byte("M")); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if decoded != KeyM {
|
|
t.Fatalf("decoded key = %v, want %v", decoded, KeyM)
|
|
}
|
|
}
|
|
|
|
func TestNamedKeyTextStillRoundTrips(t *testing.T) {
|
|
encoded, err := KeyCtrlT.MarshalText()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var decoded Key
|
|
if err := decoded.UnmarshalText(encoded); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if decoded != KeyCtrlT {
|
|
t.Fatalf("decoded key = %v, want %v", decoded, KeyCtrlT)
|
|
}
|
|
}
|