forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OpenZeppelin#601 from elopio/test/math
test: add tests for max64 and min64 from Math
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var MathMock = artifacts.require('./mocks/MathMock.sol'); | ||
|
||
contract('Math', function (accounts) { | ||
let math; | ||
|
||
before(async function () { | ||
math = await MathMock.new(); | ||
}); | ||
|
||
it('returns max correctly', async function () { | ||
let a = 5678; | ||
let b = 1234; | ||
await math.max64(a, b); | ||
let result = await math.result(); | ||
assert.equal(result, a); | ||
}); | ||
|
||
it('returns min correctly', async function () { | ||
let a = 5678; | ||
let b = 1234; | ||
await math.min64(a, b); | ||
let result = await math.result(); | ||
assert.equal(result, b); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
|
||
import '../../contracts/math/Math.sol'; | ||
|
||
|
||
contract MathMock { | ||
uint64 public result; | ||
|
||
function max64(uint64 a, uint64 b) public { | ||
result = Math.max64(a, b); | ||
} | ||
|
||
function min64(uint64 a, uint64 b) public { | ||
result = Math.min64(a, b); | ||
} | ||
} |