func TestIncreaseBalance(t *testing.T) { var btcInit uint64 = 90000 var skyInit uint64 = 450000 testData := map[coin.Type][]struct { V uint64 Expect uint64 }{ coin.Bitcoin: { {10000, 100000}, {20000, 110000}, {1000, 91000}, {100, 90100}, }, coin.Skycoin: { {10000, 460000}, {30000, 480000}, {50000, 500000}, }, } for cp, tds := range testData { for _, d := range tds { a := account.ExchangeAccount{ Balance: map[coin.Type]uint64{ coin.Bitcoin: btcInit, coin.Skycoin: skyInit, }, } if err := a.IncreaseBalance(cp, d.V); err != nil { t.Error(err) return } if a.GetBalance(cp) != d.Expect { t.Errorf("decrease %s balance failed, v:%d, expect:%d", cp, a.GetBalance(cp), d.Expect) return } } } }