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

Function TestFindLargestDecimal

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

Source from the content-addressed store, hash-verified

815}
816
817func TestFindLargestDecimal(t *testing.T) {
818 t.Run("Find largest", func(t *testing.T) {
819 amounts := map[string]decimal.Decimal{
820 "a": decimal.NewFromFloat(100.50),
821 "b": decimal.NewFromFloat(200.75),
822 "c": decimal.NewFromFloat(50.25),
823 }
824 key, amount := findLargestDecimal(amounts)
825 assert.Equal(t, "b", key)
826 assert.True(t, amount.Equal(decimal.NewFromFloat(200.75)))
827 })
828
829 t.Run("Single element", func(t *testing.T) {
830 amounts := map[string]decimal.Decimal{
831 "only": decimal.NewFromFloat(123.45),
832 }
833 key, amount := findLargestDecimal(amounts)
834 assert.Equal(t, "only", key)
835 assert.True(t, amount.Equal(decimal.NewFromFloat(123.45)))
836 })
837
838 t.Run("Empty map", func(t *testing.T) {
839 amounts := map[string]decimal.Decimal{}
840 key, amount := findLargestDecimal(amounts)
841 assert.Equal(t, "", key)
842 assert.True(t, amount.IsZero())
843 })
844}
845
846func TestHandleZeroAmount(t *testing.T) {
847 t.Run("Multiple distributions", func(t *testing.T) {

Callers

nothing calls this directly

Calls 1

findLargestDecimalFunction · 0.85

Tested by

no test coverage detected