1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2024-12-26 15:02:27 -05:00

Add test for Amount.Equal()

This commit is contained in:
Aaron Lindsay 2017-04-04 20:20:31 -04:00
parent 061b31a99d
commit 6d8578c056

View File

@ -121,6 +121,33 @@ func TestUnmarshalAmount(t *testing.T) {
unmarshalHelper2(t, "-19487135\n", &a, &overwritten, eq)
}
func TestAmountEqual(t *testing.T) {
assertEq := func(a, b ofxgo.Amount) {
if !a.Equal(b) {
t.Fatalf("Amounts should be equal but Equal returned false: %s and %s\n", a, b)
}
}
assertNEq := func(a, b ofxgo.Amount) {
if a.Equal(b) {
t.Fatalf("Amounts should not be equal but Equal returned true: %s and %s\n", a, b)
}
}
var a, b ofxgo.Amount
a.SetInt64(-19487135)
b.SetInt64(-19487135)
assertEq(a, b)
b.SetInt64(19487135)
assertNEq(a, b)
b.SetInt64(0)
assertNEq(a, b)
a.SetInt64(-0)
assertEq(a, b)
a.SetFrac64(1, 1000000000000000000)
b.SetFrac64(1, 1000000000000000001)
assertNEq(a, b)
}
func TestMarshalDate(t *testing.T) {
var d *ofxgo.Date
UTC := time.FixedZone("UTC", 0)