-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
31 lines (25 loc) · 881 Bytes
/
Copy pathmain_test.go
File metadata and controls
31 lines (25 loc) · 881 Bytes
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
package main_test
import (
"encoding/json"
"fmt"
"testing"
widget "github.com/lukasschwab/aliasing-uuids/pkg/string_type"
// widget "github.com/lukasschwab/aliasing-uuids/pkg/uuid_embed"
// widget "github.com/lukasschwab/aliasing-uuids/pkg/uuid_type"
// widget "github.com/lukasschwab/aliasing-uuids/pkg/uuid_alias"
"github.com/peterldowns/testy/assert"
)
func TestID_Marshal(t *testing.T) {
bytes, err := json.Marshal(widget.NilID)
assert.Nil(t, err)
assert.Equal(t, "\"00000000-0000-0000-0000-000000000000\"", string(bytes))
}
func TestID_Unmarshal(t *testing.T) {
widgetID := new(widget.ID)
err := json.Unmarshal([]byte("\"00000000-0000-0000-0000-000000000000\""), widgetID)
assert.Nil(t, err)
assert.Equal(t, widget.NilID, *widgetID)
}
func TestID_String(t *testing.T) {
assert.Equal(t, "00000000-0000-0000-0000-000000000000", fmt.Sprint(widget.NilID))
}