parent
299b25b8c6
commit
35ab1b28f2
@ -0,0 +1,22 @@ |
||||
pragma solidity ^0.5.0; |
||||
|
||||
import "../../examples_4/SafeMath.sol"; |
||||
import "../lib/EvenOdd.sol"; |
||||
|
||||
contract SimpleStorage is EvenOdd{ |
||||
using SafeMath for uint256; |
||||
uint public storedData; |
||||
|
||||
constructor() public { |
||||
storedData = 100; |
||||
} |
||||
|
||||
function set(uint x) public { |
||||
storedData = x; |
||||
} |
||||
|
||||
function get() public view returns (uint retVal) { |
||||
return storedData; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
pragma solidity ^0.5.0; |
||||
|
||||
contract EvenOdd { |
||||
|
||||
/** |
||||
* @dev Tells whether a number is even or odd |
||||
* @param num Number to check |
||||
*/ |
||||
|
||||
function check(int num) public pure returns (string memory){ |
||||
if(num % 2 == 0) |
||||
return "EVEN"; |
||||
return "ODD"; |
||||
} |
||||
} |
@ -0,0 +1,24 @@ |
||||
pragma solidity ^0.5.0; |
||||
import "./../contract/simple_storage.sol"; |
||||
|
||||
contract StorageResolveTest { |
||||
SimpleStorage foo; |
||||
|
||||
function beforeAll() public { |
||||
foo = new SimpleStorage(); |
||||
} |
||||
|
||||
function initialValueShouldBe100() public returns (bool) { |
||||
return Assert.equal(foo.get(), 100, "initial value is not correct"); |
||||
} |
||||
|
||||
//Test imported contract functions |
||||
function checkIfEven() public returns (bool) { |
||||
return Assert.equal(foo.check(10), 'EVEN', "value is odd"); |
||||
} |
||||
|
||||
function checkIfOdd() public returns (bool) { |
||||
return Assert.equal(foo.check(11), 'ODD', "value is even"); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue