MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestPrecisionBankersRound

Function TestPrecisionBankersRound

model/model_test.go:793–815  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

791}
792
793func 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
817func TestFindLargestDecimal(t *testing.T) {
818 t.Run("Find largest", func(t *testing.T) {

Callers

nothing calls this directly

Calls 1

PrecisionBankersRoundFunction · 0.85

Tested by

no test coverage detected