(t *testing.T)
| 791 | } |
| 792 | |
| 793 | func TestPrecisionBankersRound(t *testing.T) { |
| 794 | tests := []struct { |
| 795 | name string |
| 796 | num float64 |
| 797 | precision float64 |
| 798 | expected float64 |
| 799 | }{ |
| 800 | {"Round down", 1.234, 100, 1.23}, |
| 801 | {"Round up", 1.236, 100, 1.24}, |
| 802 | {"Banker's round even - round down", 1.225, 100, 1.22}, |
| 803 | {"Banker's round odd - round up", 1.235, 100, 1.24}, |
| 804 | {"No rounding needed", 1.50, 100, 1.50}, |
| 805 | {"Higher precision", 1.23456, 10000, 1.2346}, |
| 806 | {"Whole number", 5.0, 100, 5.0}, |
| 807 | } |
| 808 | |
| 809 | for _, tc := range tests { |
| 810 | t.Run(tc.name, func(t *testing.T) { |
| 811 | result := PrecisionBankersRound(tc.num, tc.precision) |
| 812 | assert.InDelta(t, tc.expected, result, 0.0001) |
| 813 | }) |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | func TestFindLargestDecimal(t *testing.T) { |
| 818 | t.Run("Find largest", func(t *testing.T) { |
nothing calls this directly
no test coverage detected