MCPcopy Create free account
hub / github.com/chain/txvm / TestFormatValue

Function TestFormatValue

log/log_test.go:377–399  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

375}
376
377func TestFormatValue(t *testing.T) {
378 examples := []struct {
379 value interface{}
380 want string
381 }{
382 {"hello", "hello"},
383 {"hello world", `"hello world"`},
384 {1.5, "1.5"},
385 {true, "true"},
386 {errors.New("this is an error"), `"this is an error"`},
387 {[]byte{'a', 'b', 'c'}, `"[97 98 99]"`},
388 {bytes.NewBuffer([]byte{'a', 'b', 'c'}), "abc"},
389 {"a b\"c\nd;e\tf龜g", `"a b\"c\nd;e\tf龜g"`},
390 }
391
392 for i, ex := range examples {
393 t.Log("Example", i)
394 got := formatValue(ex.value)
395 if got != ex.want {
396 t.Errorf("formatKey(%#v) = %q want %q", ex.value, got, ex.want)
397 }
398 }
399}

Callers

nothing calls this directly

Calls 2

NewFunction · 0.92
formatValueFunction · 0.85

Tested by

no test coverage detected