Commit d46a6fe3 authored by aniket-engg's avatar aniket-engg Committed by Aniket

lesserthan uint done

parent bbf72ccb
...@@ -134,9 +134,9 @@ library Assert { ...@@ -134,9 +134,9 @@ library Assert {
emit AssertionEvent(result, message); emit AssertionEvent(result, message);
} }
/*----------------- Lesser than --------------------*/ /*----------------- Lesser than --------------------*/
function lesserThan(uint a, uint b, string memory message) public returns (bool result) { function lesserThan(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a < b); result = (a < b);
emit AssertionEvent(result, message); emit AssertionEventUint(result, message, a, b);
} }
function lesserThan(int a, int b, string memory message) public returns (bool result) { function lesserThan(int a, int b, string memory message) public returns (bool result) {
......
import "remix_tests.sol"; // this import is automatically injected by Remix.
contract AssertLesserThanTest {
function lesserThanUintPassTest() public {
Assert.lesserThan(uint(2), uint(5), "lesserThanUintPassTest passes");
}
function lesserThanUintFailTest() public {
Assert.lesserThan(uint(4), uint(2), "lesserThanUintFailTest fails");
}
}
\ No newline at end of file
...@@ -218,6 +218,35 @@ describe('testRunner', () => { ...@@ -218,6 +218,35 @@ describe('testRunner', () => {
}) })
}) })
describe('assert library LESSERTHAN method tests', () => {
const filename: string = __dirname + '/examples_0/assert_lesserThan_test.sol'
beforeAll((done) => {
compileAndDeploy(filename, (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) => {
runTest('AssertLesserThanTest', contracts.AssertLesserThanTest, compilationData[filename]['AssertLesserThanTest'], 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: 'AssertLesserThanTest', filename: __dirname + '/examples_0/assert_lesserThan_test.sol' },
{ type: 'testPass', value: 'Lesser than uint pass test', context: 'AssertLesserThanTest' },
{ type: 'testFailure', value: 'Lesser than uint fail test', errMsg: 'lesserThanUintFailTest fails', context: 'AssertLesserThanTest', expected: '2', returned: '4'}
], ['time'])
})
})
describe('test with beforeAll', () => { describe('test with beforeAll', () => {
const filename: string = __dirname + '/examples_1/simple_storage_test.sol' const filename: string = __dirname + '/examples_1/simple_storage_test.sol'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment