From f162638cdea5defdc04e0bffcadc25bcec57d6f4 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 6 Dec 2017 06:37:45 +0000 Subject: [PATCH 1/2] test: add tests for max64 and min64 from Math --- test/Math.test.js | 26 ++++++++++++++++++++++++++ test/mocks/MathMock.sol | 17 +++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/Math.test.js create mode 100644 test/mocks/MathMock.sol diff --git a/test/Math.test.js b/test/Math.test.js new file mode 100644 index 00000000000..4b382cfadbc --- /dev/null +++ b/test/Math.test.js @@ -0,0 +1,26 @@ +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); + }); + +}); diff --git a/test/mocks/MathMock.sol b/test/mocks/MathMock.sol new file mode 100644 index 00000000000..8b6401e5756 --- /dev/null +++ b/test/mocks/MathMock.sol @@ -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); + } +} From fdfd90e6a4da5f1dc9e75137b979e494786ff824 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 6 Dec 2017 14:57:41 +0000 Subject: [PATCH 2/2] fix the eslint static check --- test/Math.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Math.test.js b/test/Math.test.js index 4b382cfadbc..7378610b61c 100644 --- a/test/Math.test.js +++ b/test/Math.test.js @@ -22,5 +22,4 @@ contract('Math', function (accounts) { let result = await math.result(); assert.equal(result, b); }); - });