Skip to content

Commit

Permalink
improved tests (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman authored Apr 26, 2021
1 parent b323bdc commit 46b8ad9
Showing 1 changed file with 40 additions and 7 deletions.
47 changes: 40 additions & 7 deletions uint256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,46 @@ func testRandomOp(t *testing.T, nativeFunc func(a, b, c *Int), bigintFunc func(a
if err != nil {
t.Fatal(err)
}
f1a, f2a := f1.Clone(), f2.Clone()
nativeFunc(f1, f1, f2)
bigintFunc(b1, b1, b2)
//checkOverflow(b, f1, overflow)
if eq := checkEq(b1, f1); !eq {
bf, _ := FromBig(b1)
t.Fatalf("Expected equality:\nf1= %x\nf2= %x\n[ op ]==\nf = %x\nbf= %x\nb = %x\n", f1a, f2a, f1, bf, b1)
{ // Tests the op on the form: a.foo( a, b)
f1a, f2a := f1.Clone(), f2.Clone()
b1a, b2a := new(big.Int).Set(b1), new(big.Int).Set(b2)
nativeFunc(f1a, f1a, f2a)
bigintFunc(b1a, b1a, b2a)
//checkOverflow(b, f1, overflow)
if eq := checkEq(b1a, f1a); !eq {
bf, _ := FromBig(b1)
t.Fatalf("Expected equality:\nf1= %x\nf2= %x\n[ op ]==\nf = %x\nbf= %x\nb = %x\n", f1a, f2a, f1, bf, b1a)
}
}
{ // Tests the op on the form: a.foo( b, a)
f1a, f2a := f1.Clone(), f2.Clone()
b1a, b2a := new(big.Int).Set(b1), new(big.Int).Set(b2)
nativeFunc(f1a, f2a, f1a)
bigintFunc(b1a, b2a, b1a)
if eq := checkEq(b1a, f1a); !eq {
bf, _ := FromBig(b1)
t.Fatalf("Expected equality:\nf1= %x\nf2= %x\n[ op ]==\nf = %x\nbf= %x\nb = %x\n", f1a, f2a, f1, bf, b1a)
}
}
{ // Tests the op on the form: a.foo( a , a)
f1a := f1.Clone()
b1a := new(big.Int).Set(b1)
nativeFunc(f1a, f1a, f1a)
bigintFunc(b1a, b1a, b1a)
if eq := checkEq(b1a, f1a); !eq {
bf, _ := FromBig(b1)
t.Fatalf("Expected equality:\nf1= %x\nf2= %x\n[ op ]==\nf = %x\nbf= %x\nb = %x\n", f1a, f1a, f1, bf, b1a)
}
}
{ // Tests the op on the form: a.foo( b , b)
f1a, f2a := f1.Clone(), f2.Clone()
b1a, b2a := new(big.Int).Set(b1), new(big.Int).Set(b2)
nativeFunc(f1a, f2a, f2a)
bigintFunc(b1a, b2a, b2a)
if eq := checkEq(b1a, f1a); !eq {
bf, _ := FromBig(b1)
t.Fatalf("Expected equality:\nf1= %x\nf2= %x\n[ op ]==\nf = %x\nbf= %x\nb = %x\n", f2a, f2a, f1, bf, b1a)
}
}
}
}
Expand Down

0 comments on commit 46b8ad9

Please sign in to comment.