Skip to content

Commit 919b80a

Browse files
wildarchconnorkuehl
authored andcommitted
Add test for marshalling KeyValueQcode.
1 parent 2002801 commit 919b80a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

qmp/raw/raw_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package raw
2+
3+
import (
4+
"bytes"
5+
"testing"
6+
)
7+
8+
func TestKeyValueQcode(t *testing.T) {
9+
key := QKeyCodeShift
10+
code := KeyValueQcode(key)
11+
json, err := code.MarshalJSON()
12+
expectedJSON := []byte(`{"data":"shift","type":"qcode"}`)
13+
if err != nil {
14+
t.Fatalf("Failed to marshall %v: %s", code, err)
15+
}
16+
if !bytes.Equal(json, expectedJSON) {
17+
t.Fatalf("Expected %s, but output was %s", expectedJSON, json)
18+
}
19+
}

0 commit comments

Comments
 (0)