forked from mattstam/solidity-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCounter.t.sol
52 lines (43 loc) · 1.24 KB
/
Counter.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.17;
import {Test} from "./utils/Test.sol";
import {Counter} from "../Counter.sol";
contract CounterTest is Test {
Counter counter;
function setUp() public {
counter = new Counter(5);
}
function testIncrement() public {
counter.incrementCount();
counter.incrementCount();
int256 value = counter.getCount();
assertEq(value, 7);
emit log_int(value);
}
function testDecrement() public {
counter.decrementCount();
int256 value = counter.getCount();
assertEq(value, 4);
emit log_int(value);
}
function testGetCount() public {
int256 value = counter.getCount();
assertEq(value, 5);
emit log_int(value);
}
function testSetCount() public {
counter.setCount(10);
int256 value = counter.getCount();
assertEq(value, 10);
emit log_int(value);
}
function testSetCountAfterIncrement() public {
counter.incrementCount();
counter.incrementCount();
counter.incrementCount();
counter.setCount(3);
int256 value = counter.getCount();
assertEq(value, 3);
emit log_int(value);
}
}