greater than uint done

pull/370/head
aniket-engg 4 years ago committed by Aniket
parent a34d1bdf84
commit bbf72ccb9b
  1. 4
      libs/remix-tests/sol/tests.sol.ts
  2. 12
      libs/remix-tests/tests/examples_0/assert_greaterThan_test.sol
  3. 29
      libs/remix-tests/tests/testRunner.spec.ts

@ -105,9 +105,9 @@ library Assert {
}
/*----------------- Greater than --------------------*/
function greaterThan(uint a, uint b, string memory message) public returns (bool result) {
function greaterThan(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a > b);
emit AssertionEvent(result, message);
emit AssertionEventUint(result, message, a, b);
}
function greaterThan(int a, int b, string memory message) public returns (bool result) {

@ -0,0 +1,12 @@
import "remix_tests.sol"; // this import is automatically injected by Remix.
contract AssertGreaterThanTest {
function greaterThanUintPassTest() public {
Assert.greaterThan(uint(5), uint(2), "greaterThanUintPassTest passes");
}
function greaterThanUintFailTest() public {
Assert.greaterThan(uint(1), uint(4), "greaterThanUintFailTest fails");
}
}

@ -189,6 +189,35 @@ describe('testRunner', () => {
})
})
describe('assert library GREATERTHAN method tests', () => {
const filename: string = __dirname + '/examples_0/assert_greaterThan_test.sol'
beforeAll((done) => {
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => {
runTest('AssertGreaterThanTest', contracts.AssertGreaterThanTest, compilationData[filename]['AssertGreaterThanTest'], asts[filename], { accounts }, testCallback, resultsCallback(done))
})
})
afterAll(() => { tests = [] })
it('should have 1 passing test', () => {
assert.equal(results.passingNum, 1)
})
it('should have 1 failing test', () => {
assert.equal(results.failureNum, 1)
})
it('should return', () => {
deepEqualExcluding(tests, [
{ type: 'accountList', value: accounts },
{ type: 'contract', value: 'AssertGreaterThanTest', filename: __dirname + '/examples_0/assert_greaterThan_test.sol' },
{ type: 'testPass', value: 'Greater than uint pass test', context: 'AssertGreaterThanTest' },
{ type: 'testFailure', value: 'Greater than uint fail test', errMsg: 'greaterThanUintFailTest fails', context: 'AssertGreaterThanTest', expected: '4', returned: '1'}
], ['time'])
})
})
describe('test with beforeAll', () => {
const filename: string = __dirname + '/examples_1/simple_storage_test.sol'

Loading…
Cancel
Save