go test -v -run=^$ -bench=Benchmark_Utils_GetOffer -benchmem -count=4
(b *testing.B)
| 251 | |
| 252 | // go test -v -run=^$ -bench=Benchmark_Utils_GetOffer -benchmem -count=4 |
| 253 | func Benchmark_Utils_GetOffer(b *testing.B) { |
| 254 | testCases := []struct { |
| 255 | description string |
| 256 | accept string |
| 257 | offers []string |
| 258 | }{ |
| 259 | { |
| 260 | description: "simple", |
| 261 | accept: "application/json", |
| 262 | offers: []string{"application/json"}, |
| 263 | }, |
| 264 | { |
| 265 | description: "6 offers", |
| 266 | accept: "text/plain", |
| 267 | offers: []string{"junk/a", "junk/b", "junk/c", "junk/d", "junk/e", "text/plain"}, |
| 268 | }, |
| 269 | { |
| 270 | description: "1 parameter", |
| 271 | accept: "application/json; version=1", |
| 272 | offers: []string{"application/json;version=1"}, |
| 273 | }, |
| 274 | { |
| 275 | description: "2 parameters", |
| 276 | accept: "application/json; version=1; foo=bar", |
| 277 | offers: []string{"application/json;version=1;foo=bar"}, |
| 278 | }, |
| 279 | { |
| 280 | description: "3 parameters", |
| 281 | accept: "application/json; version=1; foo=bar; charset=utf-8", |
| 282 | offers: []string{"application/json;version=1;foo=bar;charset=utf-8"}, |
| 283 | }, |
| 284 | { |
| 285 | description: "10 parameters", |
| 286 | accept: "text/plain;a=1;b=2;c=3;d=4;e=5;f=6;g=7;h=8;i=9;j=10", |
| 287 | offers: []string{"text/plain;a=1;b=2;c=3;d=4;e=5;f=6;g=7;h=8;i=9;j=10"}, |
| 288 | }, |
| 289 | { |
| 290 | description: "6 offers w/params", |
| 291 | accept: "text/plain; format=flowed", |
| 292 | offers: []string{ |
| 293 | "junk/a;a=b", |
| 294 | "junk/b;b=c", |
| 295 | "junk/c;c=d", |
| 296 | "text/plain; format=justified", |
| 297 | "text/plain; format=flat", |
| 298 | "text/plain; format=flowed", |
| 299 | }, |
| 300 | }, |
| 301 | { |
| 302 | description: "mime extension", |
| 303 | accept: "utf-8, iso-8859-1;q=0.5", |
| 304 | offers: []string{"utf-8"}, |
| 305 | }, |
| 306 | { |
| 307 | description: "mime extension", |
| 308 | accept: "utf-8, iso-8859-1;q=0.5", |
| 309 | offers: []string{"iso-8859-1"}, |
| 310 | }, |
nothing calls this directly
no test coverage detected