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")
	}
}
TestCurrencyDiv checks that the div function has been correctly implemented.
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)
		}
	}
}