(t *testing.T)
| 658 | } |
| 659 | |
| 660 | func TestQuantize(t *testing.T) { |
| 661 | tests := []struct { |
| 662 | s string |
| 663 | e int32 |
| 664 | expect string |
| 665 | }{ |
| 666 | { |
| 667 | s: "1.00", |
| 668 | e: -1, |
| 669 | expect: "1.0", |
| 670 | }, |
| 671 | { |
| 672 | s: "2.0", |
| 673 | e: -1, |
| 674 | expect: "2.0", |
| 675 | }, |
| 676 | { |
| 677 | s: "3", |
| 678 | e: -1, |
| 679 | expect: "3.0", |
| 680 | }, |
| 681 | { |
| 682 | s: "9.9999", |
| 683 | e: -2, |
| 684 | expect: "10.00", |
| 685 | }, |
| 686 | } |
| 687 | c := BaseContext.WithPrecision(10) |
| 688 | for _, tc := range tests { |
| 689 | t.Run(fmt.Sprintf("%s: %d", tc.s, tc.e), func(t *testing.T) { |
| 690 | d, _, err := NewFromString(tc.s) |
| 691 | if err != nil { |
| 692 | t.Fatal(err) |
| 693 | } |
| 694 | if _, err := c.Quantize(d, d, tc.e); err != nil { |
| 695 | t.Fatal(err) |
| 696 | } |
| 697 | s := d.String() |
| 698 | if s != tc.expect { |
| 699 | t.Fatalf("expected: %s, got: %s", tc.expect, s) |
| 700 | } |
| 701 | }) |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | func TestCmpOrder(t *testing.T) { |
| 706 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…