File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ //SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^ 0.8.12 ;
4
+
5
+ contract SimpleStorage {
6
+ uint8 public storedData;
7
+
8
+ function setAddition (uint8 x ) public {
9
+ storedData = x * 2 ;
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^ 0.8.13 ;
3
+
4
+ import "forge-std/Test.sol " ;
5
+ import "../src/SimpleStorage.sol " ;
6
+
7
+ contract SimplestorageTest is Test {
8
+ SimpleStorage simpleStorage;
9
+
10
+ function setUp () public {
11
+ simpleStorage = new SimpleStorage ();
12
+ }
13
+
14
+ function testSetAdditionValid () public {
15
+ uint8 testValue = 128 ; // This value we want to test.
16
+ console.log ("Test value is: " , testValue);
17
+ simpleStorage.setAddition (testValue);
18
+ assert (simpleStorage.storedData () < 255 );
19
+ console.log ("Stored data is: " , simpleStorage.storedData ());
20
+ }
21
+
22
+ function testSetAdditionValidFuzz (uint8 testValue ) public {
23
+ // uint8 testValue = 128; Commented value
24
+ console.log ("Test value is: " , testValue);
25
+ simpleStorage.setAddition (testValue);
26
+ assert (simpleStorage.storedData () < 255 );
27
+ console.log ("Stored data is: " , simpleStorage.storedData ());
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments