improve string tests

pull/7/head
0mkar 6 years ago
parent e64c928896
commit 08c8cbeefa
  1. 6
      tests/examples_3/simple_string.sol
  2. 8
      tests/examples_3/simple_string_test.sol
  3. 17
      tests/testRunner.js

@ -3,11 +3,7 @@ contract SimpleString {
string public storedData;
function SimpleString() public {
storedData = "Hello";
}
function set(string x) public {
storedData = x;
storedData = "Hello world!";
}
function get() public view returns (string retVal) {

@ -2,7 +2,7 @@ pragma solidity ^0.4.7;
import "./tests.sol";
import "./simple_string.sol";
contract MyTest {
contract StringTest {
SimpleString foo;
function beforeAll() {
@ -10,6 +10,10 @@ contract MyTest {
}
function initialValueShouldBeHello() public constant returns (bool) {
return Assert.equal(foo.get(), "Hello", "initial value is not correct");
return Assert.equal(foo.get(), "Hello world!", "initial value is not correct");
}
function valueShouldBeHelloWorld() public constant returns (bool) {
return Assert.equal(foo.get(), "Hello wordl!", "initial value is not correct");
}
}

@ -50,7 +50,7 @@ describe('testRunner', function () {
assert.equal(results.failureNum, 2)
})
it('should returns 3 messages', function () {
it('should returns 5 messages', function () {
assert.deepEqual(tests, [
{ type: 'contract', value: 'MyTest', filename: 'simple_storage_test.sol' },
{ type: 'testFailure', value: 'Should trigger one fail', time: 1, context: 'MyTest', errMsg: 'the test 1 fails' },
@ -107,10 +107,10 @@ describe('testRunner', function () {
}
var resultsCallback = function (_err, _results) {
results = _results
console.log(results)
done()
}
TestRunner.runTest('MyTest', contracts.MyTest, testCallback, resultsCallback)
TestRunner.runTest('StringTest', contracts.StringTest, testCallback, resultsCallback)
TestRunner.runTest('StringTest2', contracts.StringTest2, testCallback, resultsCallback)
})
})
@ -118,14 +118,15 @@ describe('testRunner', function () {
assert.equal(results.passingNum, 1)
})
it('should 0 failing tests', function () {
assert.equal(results.failureNum, 0)
it('should 1 failing tests', function () {
assert.equal(results.failureNum, 1)
})
it('should returns 2 messages', function () {
it('should returns 3 messages', function () {
assert.deepEqual(tests, [
{ type: 'contract', value: 'MyTest', filename: 'simple_string_test.sol' },
{ type: 'testPass', value: 'Initial value should be hello', time: 1, context: 'MyTest' }
{ type: 'contract', value: 'StringTest', filename: 'simple_string_test.sol' },
{ type: 'testFailure', value: 'Value should be hello world', time: 1, context: 'StringTest', "errMsg": "function returned false" },
{ type: 'testPass', value: 'Initial value should be hello', time: 1, context: 'StringTest' },
])
})
})

Loading…
Cancel
Save