MCPcopy
hub / github.com/expr-lang/expr / addArrayFormatterTests

Function addArrayFormatterTests

internal/spew/format_test.go:500–583  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

498}
499
500func addArrayFormatterTests() {
501 // Array containing standard ints.
502 v := [3]int{1, 2, 3}
503 nv := (*[3]int)(nil)
504 pv := &v
505 vAddr := fmt.Sprintf("%p", pv)
506 pvAddr := fmt.Sprintf("%p", &pv)
507 vt := "[3]int"
508 vs := "[1 2 3]"
509 addFormatterTest("%v", v, vs)
510 addFormatterTest("%v", pv, "<*>"+vs)
511 addFormatterTest("%v", &pv, "<**>"+vs)
512 addFormatterTest("%+v", nv, "<nil>")
513 addFormatterTest("%+v", v, vs)
514 addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
515 addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
516 addFormatterTest("%+v", nv, "<nil>")
517 addFormatterTest("%#v", v, "("+vt+")"+vs)
518 addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
519 addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
520 addFormatterTest("%#v", nv, "(*"+vt+")"+"<nil>")
521 addFormatterTest("%#+v", v, "("+vt+")"+vs)
522 addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
523 addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
524 addFormatterTest("%#+v", nv, "(*"+vt+")"+"<nil>")
525
526 // Array containing type with custom formatter on pointer receiver only.
527 v2 := [3]pstringer{"1", "2", "3"}
528 nv2 := (*[3]pstringer)(nil)
529 pv2 := &v2
530 v2Addr := fmt.Sprintf("%p", pv2)
531 pv2Addr := fmt.Sprintf("%p", &pv2)
532 v2t := "[3]spew_test.pstringer"
533 v2sp := "[stringer 1 stringer 2 stringer 3]"
534 v2s := v2sp
535 if spew.UnsafeDisabled {
536 v2s = "[1 2 3]"
537 }
538 addFormatterTest("%v", v2, v2s)
539 addFormatterTest("%v", pv2, "<*>"+v2sp)
540 addFormatterTest("%v", &pv2, "<**>"+v2sp)
541 addFormatterTest("%+v", nv2, "<nil>")
542 addFormatterTest("%+v", v2, v2s)
543 addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2sp)
544 addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2sp)
545 addFormatterTest("%+v", nv2, "<nil>")
546 addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
547 addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2sp)
548 addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2sp)
549 addFormatterTest("%#v", nv2, "(*"+v2t+")"+"<nil>")
550 addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
551 addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2sp)
552 addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2sp)
553 addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"<nil>")
554
555 // Array containing interfaces.
556 v3 := [3]interface{}{"one", int(2), uint(3)}
557 nv3 := (*[3]interface{})(nil)

Callers 1

TestFormatterFunction · 0.85

Calls 2

addFormatterTestFunction · 0.85
SprintfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…