Skip to content

Commit 1c70463

Browse files
committed
1 parent 5f88845 commit 1c70463

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/math/SafeMath.test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,20 @@ contract('SafeMath', function () {
5353
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
5454
});
5555

56-
it('handles a zero product correctly', async function () {
56+
it('handles a zero product correctly (first number as zero)', async function () {
5757
const a = new BigNumber(0);
5858
const b = new BigNumber(5678);
5959

6060
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
6161
});
6262

63+
it('handles a zero product correctly (second number as zero)', async function () {
64+
const a = new BigNumber(5678);
65+
const b = new BigNumber(0);
66+
67+
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
68+
});
69+
6370
it('throws a revert error on multiplication overflow', async function () {
6471
const a = MAX_UINT256;
6572
const b = new BigNumber(2);
@@ -76,6 +83,20 @@ contract('SafeMath', function () {
7683
(await this.safeMath.div(a, b)).should.be.bignumber.equal(a.div(b));
7784
});
7885

86+
it('handles a zero division correctly', async function () {
87+
const a = new BigNumber(0);
88+
const b = new BigNumber(5678);
89+
90+
(await this.safeMath.div(a, b)).should.be.bignumber.equal(a.div(b));
91+
});
92+
93+
it('returns complete number resultant on non-even division', async function () {
94+
const a = new BigNumber(7000);
95+
const b = new BigNumber(5678);
96+
97+
(await this.safeMath.div(a, b)).should.be.bignumber.equal(1);
98+
});
99+
79100
it('throws a revert error on zero division', async function () {
80101
const a = new BigNumber(5678);
81102
const b = new BigNumber(0);

0 commit comments

Comments
 (0)