func TestCurrencyMul64(t *testing.T) {
	c5 := NewCurrency64(5)
	u6 := uint64(6)
	c30 := NewCurrency64(30)
	if c5.Mul64(u6).Cmp(c30) != 0 {
		t.Error("Multiplying 5 by 6 should equal 30")
	}
}
TestCurrencyMul64 probes the Mul64 function of the currency type.
package types
import (
	"math"
	"math/big"
	"testing"
)
func TestNewCurrency(t *testing.T) {
	b := big.NewInt(481)
	c := NewCurrency(b)
	if b.String() != c.String() {
		t.Error("NewCurrency does't seem to work properly")
	}
}
func TestCurrencyAdd(t *testing.T) {
	c7 := NewCurrency64(7)
	c12 := NewCurrency64(12)
	c19 := NewCurrency64(19)
	if c7.Add(c12).Cmp(c19) != 0 {
		t.Error("Add doesn't seem to work right")
	}
}
func TestCurrencyToBig(t *testing.T) {
	c := NewCurrency64(125)
	cb := c.Big()
	b := big.NewInt(125)
	if b.Cmp(cb) != 0 {
		t.Error("currency to big has failed")
	}
}
func TestCurrencyCmp(t *testing.T) {
	tests := []struct {
		x, y Currency
		exp  int
	}{
		{NewCurrency64(0), NewCurrency64(0), 0},
		{NewCurrency64(0), NewCurrency64(1), -1},
		{NewCurrency64(1), NewCurrency64(0), 1},
		{NewCurrency64(100), NewCurrency64(7), 1},
		{NewCurrency64(777), NewCurrency(big.NewInt(777)), 0},
		{NewCurrency(big.NewInt(7)), NewCurrency(big.NewInt(8)), -1},
	}
	for _, test := range tests {
		if c := test.x.Cmp(test.y); c != test.exp {
			t.Errorf("expected %v.Cmp(%v) == %v, got %v", test.x, test.y, test.exp, c)
		} else if bc := test.x.Big().Cmp(test.y.Big()); c != bc {
			t.Errorf("Currency.Cmp (%v) does not match big.Int.Cmp (%v) for %v.Cmp(%v)", c, bc, test.x, test.y)
		}
	}
}
func TestCurrencyCmp64(t *testing.T) {
	tests := []struct {
		x   Currency
		y   uint64
		exp int
	}{
		{NewCurrency64(0), 0, 0},
		{NewCurrency64(0), 1, -1},
		{NewCurrency64(1), 0, 1},
		{NewCurrency64(100), 7, 1},
		{NewCurrency64(777), 777, 0},
		{NewCurrency(big.NewInt(7)), 8, -1},
	}
	for _, test := range tests {
		if c := test.x.Cmp64(test.y); c != test.exp {
			t.Errorf("expected %v.Cmp64(%v) == %v, got %v", test.x, test.y, test.exp, c)
		} else if bc := test.x.Big().Cmp(big.NewInt(int64(test.y))); c != bc {
			t.Errorf("Currency.Cmp64 (%v) does not match big.Int.Cmp (%v) for %v.Cmp64(%v)", c, bc, test.x, test.y)
		}
	}
}
func TestCurrencyDiv(t *testing.T) {
	c9 := NewCurrency64(9)
	c10 := NewCurrency64(10)
	c90 := NewCurrency64(90)
	c97 := NewCurrency64(97)
	c90D10 := c90.Div(c10)
	if c90D10.Cmp(c9) != 0 {
		t.Error("Dividing 90 by 10 should produce 9")
	}
	c97D10 := c97.Div(c10)
	if c97D10.Cmp(c9) != 0 {
		t.Error("Dividing 97 by 10 should produce 9")
	}
}
func TestCurrencyDiv64(t *testing.T) {
	c9 := NewCurrency64(9)
	u10 := uint64(10)
	c90 := NewCurrency64(90)
	c97 := NewCurrency64(97)
	c90D10 := c90.Div64(u10)
	if c90D10.Cmp(c9) != 0 {
		t.Error("Dividing 90 by 10 should produce 9")
	}
	c97D10 := c97.Div64(u10)
	if c97D10.Cmp(c9) != 0 {
		t.Error("Dividing 97 by 10 should produce 9")
	}
}
func TestCurrencyEquals(t *testing.T) {
	tests := []struct {
		x, y Currency
		exp  bool
	}{
		{NewCurrency64(0), NewCurrency64(0), true},
		{NewCurrency64(0), NewCurrency64(1), false},
		{NewCurrency64(1), NewCurrency64(0), false},
		{NewCurrency64(100), NewCurrency64(7), false},
		{NewCurrency64(777), NewCurrency(big.NewInt(777)), true},
		{NewCurrency(big.NewInt(7)), NewCurrency(big.NewInt(8)), false},
	}
	for _, test := range tests {
		if eq := test.x.Equals(test.y); eq != test.exp {
			t.Errorf("expected %v.Equals(%v) == %v, got %v", test.x, test.y, test.exp, eq)
		} else if bc := test.x.Big().Cmp(test.y.Big()); (bc == 0) != eq {
			t.Errorf("Currency.Equals (%v) does not match big.Int.Cmp (%v) for %v.Equals(%v)", eq, bc, test.x, test.y)
		}
	}
}
func TestCurrencyEquals64(t *testing.T) {
	tests := []struct {
		x   Currency
		y   uint64
		exp bool
	}{
		{NewCurrency64(0), 0, true},
		{NewCurrency64(0), 1, false},
		{NewCurrency64(1), 0, false},
		{NewCurrency64(100), 7, false},
		{NewCurrency64(777), 777, true},
		{NewCurrency(big.NewInt(7)), 8, false},
	}
	for _, test := range tests {
		if eq := test.x.Equals64(test.y); eq != test.exp {
			t.Errorf("expected %v.Equals64(%v) == %v, got %v", test.x, test.y, test.exp, eq)
		} else if bc := test.x.Big().Cmp(big.NewInt(int64(test.y))); (bc == 0) != eq {
			t.Errorf("Currency.Equals64 (%v) does not match big.Int.Cmp (%v) for %v.Equals64(%v)", eq, bc, test.x, test.y)
		}
	}
}
func TestCurrencyMul(t *testing.T) {
	c5 := NewCurrency64(5)
	c6 := NewCurrency64(6)
	c30 := NewCurrency64(30)
	if c5.Mul(c6).Cmp(c30) != 0 {
		t.Error("Multiplying 5 by 6 should equal 30")
	}
}