forked from gookit/goutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_test.go
41 lines (32 loc) · 938 Bytes
/
util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package clipboard_test
import (
"testing"
"github.com/gookit/goutil/sysutil/clipboard"
"github.com/gookit/goutil/testutil/assert"
)
func TestGetReaderBin(t *testing.T) {
assert.NotEmpty(t, clipboard.GetReaderBin())
assert.NotEmpty(t, clipboard.GetWriterBin())
assert.NotEmpty(t, clipboard.Std())
}
func TestClipboard_read_write(t *testing.T) {
err := clipboard.WriteString("")
assert.ErrMsg(t, err, "clipboard: empty contents for write")
if !clipboard.Available() {
assert.False(t, clipboard.Available())
t.Skipf("skip test on program '%s' not found", clipboard.GetReaderBin())
return
}
err = clipboard.Reset()
assert.NoErr(t, err)
str, err := clipboard.ReadString()
assert.NoErr(t, err)
assert.Empty(t, str)
src := "hello, this is clipboard"
err = clipboard.WriteString(src)
assert.NoErr(t, err)
str, err = clipboard.ReadString()
assert.NoErr(t, err)
assert.NotEmpty(t, str)
assert.Eq(t, src, str)
}