Skip to content

Instantly share code, notes, and snippets.

@0mkara
Created October 29, 2018 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0mkara/f0e9caeb69b7c55b1246c5895f0769ab to your computer and use it in GitHub Desktop.
Save 0mkara/f0e9caeb69b7c55b1246c5895f0769ab to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.25+commit.59dbf8f1.js&optimize=false&gist=
pragma solidity ^0.4.7;
import "remix_tests.sol";
contract SimpleStorage {
uint public storedData;
function SimpleStorage() public {
storedData = 100;
}
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint retVal) {
return storedData;
}
}
pragma solidity ^0.4.7;
import "./SimpleStorage.sol";
contract SimpleStorageTest {
SimpleStorage foo;
uint i = 0;
function beforeAll() {
foo = new SimpleStorage();
}
function beforeEach() {
if (i == 1) {
foo.set(200);
}
i += 1;
}
function initialValueShouldBe100() public {
Assert.equal(foo.get(), 100, "initial value is not correct");
}
function initialValueShouldBe200() public {
Assert.equal(foo.get(), 200, "initial value is not correct");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment