(t *testing.T)
| 508 | func init() { fmt.Printf("%-0s", fmtAllowsPaddingAndMinusFlagsHelper{}) } |
| 509 | |
| 510 | func TestFormatFlags(t *testing.T) { |
| 511 | const stdD = "1.23E+56" |
| 512 | tests := []struct { |
| 513 | d string |
| 514 | fmt string |
| 515 | out string |
| 516 | }{ |
| 517 | { |
| 518 | d: stdD, |
| 519 | fmt: "%3G", |
| 520 | out: "1.23E+56", |
| 521 | }, |
| 522 | { |
| 523 | d: stdD, |
| 524 | fmt: "%010G", |
| 525 | out: "001.23E+56", |
| 526 | }, |
| 527 | { |
| 528 | d: stdD, |
| 529 | fmt: "%10G", |
| 530 | out: " 1.23E+56", |
| 531 | }, |
| 532 | { |
| 533 | d: stdD, |
| 534 | fmt: "%+G", |
| 535 | out: "+1.23E+56", |
| 536 | }, |
| 537 | { |
| 538 | d: stdD, |
| 539 | fmt: "% G", |
| 540 | out: " 1.23E+56", |
| 541 | }, |
| 542 | { |
| 543 | d: stdD, |
| 544 | fmt: "%-10G", |
| 545 | out: "1.23E+56 ", |
| 546 | }, |
| 547 | { |
| 548 | d: stdD, |
| 549 | fmt: "%-010G", |
| 550 | out: func() string { |
| 551 | if !fmtAllowsPaddingAndMinusFlags { |
| 552 | return "1.23E+56 " |
| 553 | } |
| 554 | return "001.23E+56" |
| 555 | }(), |
| 556 | }, |
| 557 | { |
| 558 | d: stdD, |
| 559 | fmt: "%0-10G", |
| 560 | out: func() string { |
| 561 | if !fmtAllowsPaddingAndMinusFlags { |
| 562 | return "1.23E+56 " |
| 563 | } |
| 564 | return "001.23E+56" |
| 565 | }(), |
| 566 | }, |
| 567 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…