Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F12339323
clipboard_test.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
clipboard_test.go
View Options
// Copyright 2013 @atotto. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
clipboard_test
import
(
"testing"
.
"github.com/atotto/clipboard"
)
func
TestCopyAndPaste
(
t
*
testing
.
T
)
{
expected
:=
"日本語"
err
:=
WriteAll
(
expected
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
actual
,
err
:=
ReadAll
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
actual
!=
expected
{
t
.
Errorf
(
"want %s, got %s"
,
expected
,
actual
)
}
}
func
TestMultiCopyAndPaste
(
t
*
testing
.
T
)
{
expected1
:=
"French: éèêëàùœç"
expected2
:=
"Weird UTF-8: 💩☃"
err
:=
WriteAll
(
expected1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
actual1
,
err
:=
ReadAll
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
actual1
!=
expected1
{
t
.
Errorf
(
"want %s, got %s"
,
expected1
,
actual1
)
}
err
=
WriteAll
(
expected2
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
actual2
,
err
:=
ReadAll
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
actual2
!=
expected2
{
t
.
Errorf
(
"want %s, got %s"
,
expected2
,
actual2
)
}
}
func
BenchmarkReadAll
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
ReadAll
()
}
}
func
BenchmarkWriteAll
(
b
*
testing
.
B
)
{
text
:=
"いろはにほへと"
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
WriteAll
(
text
)
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 15, 9:54 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3491853
Attached To
rWAGTK writeas-gtk
Event Timeline
Log In to Comment