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 a6889776f4.
* updates
* fixes #1404
* approve failing test
* suggested changes done
* ISafeERC20 removed
* conflict fixes
* fixes #1386
* Update SafeMath.test.js
This commit is contained in:
@ -53,13 +53,20 @@ contract('SafeMath', function () {
|
|||||||
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
|
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles a zero product correctly', async function () {
|
it('handles a zero product correctly (first number as zero)', async function () {
|
||||||
const a = new BigNumber(0);
|
const a = new BigNumber(0);
|
||||||
const b = new BigNumber(5678);
|
const b = new BigNumber(5678);
|
||||||
|
|
||||||
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
|
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles a zero product correctly (second number as zero)', async function () {
|
||||||
|
const a = new BigNumber(5678);
|
||||||
|
const b = new BigNumber(0);
|
||||||
|
|
||||||
|
(await this.safeMath.mul(a, b)).should.be.bignumber.equal(a.times(b));
|
||||||
|
});
|
||||||
|
|
||||||
it('throws a revert error on multiplication overflow', async function () {
|
it('throws a revert error on multiplication overflow', async function () {
|
||||||
const a = MAX_UINT256;
|
const a = MAX_UINT256;
|
||||||
const b = new BigNumber(2);
|
const b = new BigNumber(2);
|
||||||
@ -76,6 +83,20 @@ contract('SafeMath', function () {
|
|||||||
(await this.safeMath.div(a, b)).should.be.bignumber.equal(a.div(b));
|
(await this.safeMath.div(a, b)).should.be.bignumber.equal(a.div(b));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('divides zero correctly', async function () {
|
||||||
|
const a = new BigNumber(0);
|
||||||
|
const b = new BigNumber(5678);
|
||||||
|
|
||||||
|
(await this.safeMath.div(a, b)).should.be.bignumber.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns complete number result on non-even division', async function () {
|
||||||
|
const a = new BigNumber(7000);
|
||||||
|
const b = new BigNumber(5678);
|
||||||
|
|
||||||
|
(await this.safeMath.div(a, b)).should.be.bignumber.equal(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('throws a revert error on zero division', async function () {
|
it('throws a revert error on zero division', async function () {
|
||||||
const a = new BigNumber(5678);
|
const a = new BigNumber(5678);
|
||||||
const b = new BigNumber(0);
|
const b = new BigNumber(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user