MCPcopy Create free account
hub / github.com/expr-lang/expr / addChanFormatterTests

Function addChanFormatterTests

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

Source from the content-addressed store, hash-verified

1130}
1131
1132func addChanFormatterTests() {
1133 // Nil channel.
1134 var v chan int
1135 pv := &v
1136 nv := (*chan int)(nil)
1137 vAddr := fmt.Sprintf("%p", pv)
1138 pvAddr := fmt.Sprintf("%p", &pv)
1139 vt := "chan int"
1140 vs := "<nil>"
1141 addFormatterTest("%v", v, vs)
1142 addFormatterTest("%v", pv, "<*>"+vs)
1143 addFormatterTest("%v", &pv, "<**>"+vs)
1144 addFormatterTest("%+v", nv, "<nil>")
1145 addFormatterTest("%+v", v, vs)
1146 addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs)
1147 addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs)
1148 addFormatterTest("%+v", nv, "<nil>")
1149 addFormatterTest("%#v", v, "("+vt+")"+vs)
1150 addFormatterTest("%#v", pv, "(*"+vt+")"+vs)
1151 addFormatterTest("%#v", &pv, "(**"+vt+")"+vs)
1152 addFormatterTest("%#v", nv, "(*"+vt+")"+"<nil>")
1153 addFormatterTest("%#+v", v, "("+vt+")"+vs)
1154 addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs)
1155 addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs)
1156 addFormatterTest("%#+v", nv, "(*"+vt+")"+"<nil>")
1157
1158 // Real channel.
1159 v2 := make(chan int)
1160 pv2 := &v2
1161 v2Addr := fmt.Sprintf("%p", pv2)
1162 pv2Addr := fmt.Sprintf("%p", &pv2)
1163 v2t := "chan int"
1164 v2s := fmt.Sprintf("%p", v2)
1165 addFormatterTest("%v", v2, v2s)
1166 addFormatterTest("%v", pv2, "<*>"+v2s)
1167 addFormatterTest("%v", &pv2, "<**>"+v2s)
1168 addFormatterTest("%+v", v2, v2s)
1169 addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s)
1170 addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s)
1171 addFormatterTest("%#v", v2, "("+v2t+")"+v2s)
1172 addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s)
1173 addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s)
1174 addFormatterTest("%#+v", v2, "("+v2t+")"+v2s)
1175 addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s)
1176 addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s)
1177}
1178
1179func addFuncFormatterTests() {
1180 // Function with no params and no returns.

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…