Skip to content

Commit b5892a2

Browse files
Aniket-Enggnventuro
authored andcommitted
SafeMath Test Coverage Improved (#1477)
* signing prefix added * Minor improvement * Tests changed * Successfully tested * Minor improvements * Minor improvements * Revert "Dangling commas are now required. (#1359)" This reverts commit a688977. * updates * fixes #1404 * approve failing test * suggested changes done * ISafeERC20 removed * conflict fixes * fixes #1386 * Update SafeMath.test.js
1 parent 4f356e3 commit b5892a2

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('divides zero 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(0);
91+
});
92+
93+
it('returns complete number result 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)