Skip to content

Commit

Permalink
Merge pull request #3 from TruCol/document
Browse files Browse the repository at this point in the history
Documented code, included additional tests, removed lint check from CI because it conflicts with pre-commit.
  • Loading branch information
a-t-0 authored Mar 28, 2024
2 parents 041572b + cbc9303 commit c8e4330
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
branches:
- "main"

jobs:
build:
runs-on: "ubuntu-latest"
steps:
Expand Down
10 changes: 10 additions & 0 deletions src/Foo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
pragma solidity >=0.8.23;

contract Foo {
/**
* @notice This returns the value that it is given.
* @dev The current dev does not yet know what the permissible range of the
* uint256 values may be, nor how this function handles a None/void/null
* input if those exist in Solidity. Nor do I know how it handles with an
* overflow input value, if that is possible.
* @param value An integer that is assumed to be stored in a 256 bit memory.
* @return The value that it receives as input. The developer does not yet
* know whether Solidity passes uint256 variables by value or by reference.
*/
function id(uint256 value) external pure returns (uint256) {
return value;
}
Expand Down
12 changes: 12 additions & 0 deletions test/Foo.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ contract FooTest is PRBTest, StdCheats {
assertEq(foo.id(x), x, "value mismatch");
}

/// @dev Basic test. Run it with `forge test -vvv` to see the console log.
function test_zero_input() external {
uint256 x = 0;
assertEq(foo.id(x), x, "value mismatch");
}

/// @dev Basic test. Run it with `forge test -vvv` to see the console log.
function test_negative_zero_input() external {
uint256 x = -0;
assertEq(foo.id(x), x, "value mismatch");
}

/// @dev Fuzz test that provides random values for an unsigned integer, but which rejects zero as an input.
/// If you need more sophisticated input validation, you should use the `bound` utility instead.
/// See https://twitter.com/PaulRBerg/status/1622558791685242880
Expand Down

0 comments on commit c8e4330

Please sign in to comment.