From f05b2858f4da9091cbe7a8fec7f0a74b308c1a4b Mon Sep 17 00:00:00 2001 From: vcaesar Date: Thu, 20 Feb 2020 11:23:49 -0400 Subject: [PATCH] update clipboard code and add test code --- robotgo.go | 6 +++--- robotgo_test.go | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/robotgo.go b/robotgo.go index ee3eff1..056e2ea 100644 --- a/robotgo.go +++ b/robotgo.go @@ -700,8 +700,8 @@ func ReadAll() (string, error) { } // WriteAll write string to clipboard -func WriteAll(text string) { - clipboard.WriteAll(text) +func WriteAll(text string) error { + return clipboard.WriteAll(text) } // CharCodeAt char code at utf-8 @@ -791,7 +791,7 @@ func PasteStr(str string) string { if runtime.GOOS == "darwin" { return KeyTap("v", "command") } - + return KeyTap("v", "control") } diff --git a/robotgo_test.go b/robotgo_test.go index 69a7c4b..d3a4469 100644 --- a/robotgo_test.go +++ b/robotgo_test.go @@ -105,6 +105,15 @@ func TestKey(t *testing.T) { tt.Empty(t, e) } +func TestClip(t *testing.T) { + err := WriteAll("s") + tt.Nil(t, err) + + s, e := ReadAll() + tt.Equal(t, "s", s) + tt.Nil(t, e) +} + func TestTypeStr(t *testing.T) { c := CharCodeAt("s", 0) tt.Equal(t, 115, c)