MCPcopy Index your code
hub / github.com/tinylib/msgp / TestEncodeDecode

Function TestEncodeDecode

msgp/write_bytes_test.go:434–562  ·  view source on GitHub ↗

TestEncodeDecode does a back-and-forth test of encoding and decoding and compare the value with a given output.

(t *testing.T)

Source from the content-addressed store, hash-verified

432
433// TestEncodeDecode does a back-and-forth test of encoding and decoding and compare the value with a given output.
434func TestEncodeDecode(t *testing.T) {
435 for _, tc := range []struct {
436 name string
437 input any
438 output any
439 encodeError string
440 }{
441 {
442 name: "nil",
443 input: nil,
444 },
445 {
446 name: "bool",
447 input: true,
448 },
449 {
450 name: "int",
451 input: int64(42),
452 },
453 {
454 name: "float",
455 input: 3.14159,
456 },
457 {
458 name: "string",
459 input: "hello",
460 },
461 {
462 name: "bytes",
463 input: []byte("hello"),
464 },
465 {
466 name: "array-empty",
467 input: []any{},
468 },
469 {
470 name: "array",
471 input: []any{int64(1), int64(2), int64(3)},
472 },
473 {
474 name: "map-empty",
475 input: map[string]any{},
476 },
477 {
478 name: "map",
479 input: map[string]any{"a": int64(1), "b": int64(2)},
480 },
481 {
482 name: "map-interface",
483 input: map[string]any{"a": int64(1), "b": "2"},
484 },
485 {
486 name: "map-string",
487 input: map[string]string{"a": "1", "b": "2"},
488 output: map[string]any{"a": "1", "b": "2"},
489 },
490 {
491 name: "map-array",

Callers

nothing calls this directly

Calls 3

AppendIntfFunction · 0.85
ReadIntfBytesFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…