MCPcopy
hub / github.com/maxpert/marmot / TestMarshal_Basic

Function TestMarshal_Basic

encoding/msgpack_test.go:8–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestMarshal_Basic(t *testing.T) {
9 tests := []struct {
10 name string
11 input interface{}
12 }{
13 {"string", "hello world"},
14 {"int", 12345},
15 {"int64", int64(9876543210)},
16 {"float64", 3.14159},
17 {"bool", true},
18 {"slice", []int{1, 2, 3, 4, 5}},
19 {"map", map[string]interface{}{"name": "alice", "age": 30}},
20 {"nested", map[string]interface{}{
21 "user": map[string]interface{}{
22 "id": 123,
23 "name": "bob",
24 },
25 "items": []string{"a", "b", "c"},
26 }},
27 }
28
29 for _, tc := range tests {
30 t.Run(tc.name, func(t *testing.T) {
31 data, err := Marshal(tc.input)
32 if err != nil {
33 t.Fatalf("Marshal failed: %v", err)
34 }
35 if len(data) == 0 {
36 t.Error("Expected non-empty result")
37 }
38 })
39 }
40}
41
42func TestMarshal_Concurrent(t *testing.T) {
43 var wg sync.WaitGroup

Callers

nothing calls this directly

Calls 3

MarshalFunction · 0.85
FatalfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected