123456789101112131415161718192021222324252627282930 |
- package borealis
- import (
- "encoding/json"
- "testing"
- )
- func TestEncodeEvent(t *testing.T) {
- event := Event{Type: 0x1234}
- output, err := json.Marshal(event)
- if err != nil {
- t.Error(err)
- }
- actual := string(output)
- expected := "[4660]"
- if actual != expected {
- t.Errorf("expected %v, but got %v", expected, actual)
- }
- }
- func TestDecodeEvent(t *testing.T) {
- var actual Event
- if err := json.Unmarshal([]byte("[4660]"), &actual); err != nil {
- t.Error(err)
- }
- expected := Event{Type: 0x1234}
- if actual != expected {
- t.Errorf("expected %v, but got %v", expected, actual)
- }
- }
|