Skip to content

Commit

Permalink
Strengthen tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Aug 27, 2023
1 parent 2466c87 commit 1a61274
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
32 changes: 16 additions & 16 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -372,29 +372,29 @@ FixedPointMathLibTest:testSqrtHashedSingle() (gas: 53086)
FixedPointMathLibTest:testZeroFloorSub(uint256,uint256) (runs: 256, μ: 548, ~: 518)
FixedPointMathLibTest:testZeroFloorSubCasted(uint32,uint32,uint256) (runs: 256, μ: 905, ~: 945)
FixedPointMathLibTest:test__codesize() (gas: 19246)
JSONParserLibTest:testDecodeEncodedStringDoesNotRevert(string) (runs: 256, μ: 48763, ~: 42931)
JSONParserLibTest:testDecodeInvalidStringReverts() (gas: 154393)
JSONParserLibTest:testDecodeString() (gas: 174062)
JSONParserLibTest:testDecodeEncodedStringDoesNotRevert(string) (runs: 256, μ: 69438, ~: 59459)
JSONParserLibTest:testDecodeInvalidStringReverts() (gas: 156703)
JSONParserLibTest:testDecodeString() (gas: 177212)
JSONParserLibTest:testParseEmptyArrays() (gas: 627001)
JSONParserLibTest:testParseEmptyObjects() (gas: 627984)
JSONParserLibTest:testParseGas() (gas: 125792)
JSONParserLibTest:testParseInt() (gas: 159666)
JSONParserLibTest:testParseInvalidIntReverts() (gas: 187675)
JSONParserLibTest:testParseInvalidNumberReverts() (gas: 3847942)
JSONParserLibTest:testParseInvalidReverts() (gas: 8247458)
JSONParserLibTest:testParseInvalidStringReverts() (gas: 1171032)
JSONParserLibTest:testParseInvalidUintReverts() (gas: 282585)
JSONParserLibTest:testParseInt() (gas: 162186)
JSONParserLibTest:testParseInvalidIntReverts() (gas: 190405)
JSONParserLibTest:testParseInvalidNumberReverts() (gas: 3874192)
JSONParserLibTest:testParseInvalidReverts() (gas: 8289458)
JSONParserLibTest:testParseInvalidStringReverts() (gas: 1991625)
JSONParserLibTest:testParseInvalidUintReverts() (gas: 285735)
JSONParserLibTest:testParseNumber() (gas: 845913)
JSONParserLibTest:testParseObject() (gas: 50333)
JSONParserLibTest:testParseRecursiveObject() (gas: 102215)
JSONParserLibTest:testParseRecursiveObject() (gas: 102425)
JSONParserLibTest:testParseSimpleArray() (gas: 24503)
JSONParserLibTest:testParseSimpleUintArray() (gas: 1241502)
JSONParserLibTest:testParseSpecials() (gas: 306277)
JSONParserLibTest:testParseString() (gas: 1236622)
JSONParserLibTest:testParseUint() (gas: 83386)
JSONParserLibTest:testParseUint(uint256) (runs: 256, μ: 33144, ~: 27130)
JSONParserLibTest:testParseValidObjectDoesNotRevert(string,string) (runs: 256, μ: 59658, ~: 57060)
JSONParserLibTest:test__codesize() (gas: 32690)
JSONParserLibTest:testParseSpecials() (gas: 306487)
JSONParserLibTest:testParseString() (gas: 1431848)
JSONParserLibTest:testParseUint() (gas: 84856)
JSONParserLibTest:testParseUint(uint256) (runs: 256, μ: 34039, ~: 29510)
JSONParserLibTest:testParseValidObjectDoesNotRevert(string,string) (runs: 256, μ: 60609, ~: 57772)
JSONParserLibTest:test__codesize() (gas: 33357)
LibBitTest:testAnd() (gas: 185677)
LibBitTest:testAnd(bool,bool) (runs: 256, μ: 668, ~: 667)
LibBitTest:testAutoClean(uint256,uint256) (runs: 256, μ: 446, ~: 446)
Expand Down
10 changes: 10 additions & 0 deletions test/JSONParserLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ contract JSONParserLibTest is SoladyTest {
_checkParseString('"01234567890123456789012345678901"');
_checkParseString('"012345678901234567890123456789012"');
_checkParseString('"0123456789012345678901234567890123"');
_checkParseString('" d"');
_checkParseString('"d "');
_checkParseString('" d "');
_checkParseString('"\\""');
_checkParseString('"\\\\"');
_checkParseString('"\\/"');
Expand All @@ -419,6 +422,7 @@ contract JSONParserLibTest is SoladyTest {
_checkParseString('"\\n"');
_checkParseString('"\\r"');
_checkParseString('"\\t"');
_checkParseString('" \\u1234 \\"\\"\\\\ \\b\\f \\n\\r "');
_checkParseString('"\\u1234"');
_checkParseString('"\\uabcd"');
_checkParseString('"\\uABCD"');
Expand Down Expand Up @@ -446,6 +450,11 @@ contract JSONParserLibTest is SoladyTest {
function testParseInvalidStringReverts() public {
_checkParseReverts('"');
_checkParseReverts('"""');
_checkParseReverts('""""');
_checkParseReverts('"""""');
_checkParseReverts('"abc" "');
_checkParseReverts('"abc" ""');
_checkParseReverts('"abc""abc"');
_checkParseReverts('"\\"');
_checkParseReverts('"\\\\\\"');
_checkParseReverts('"\\u"');
Expand Down Expand Up @@ -605,6 +614,7 @@ contract JSONParserLibTest is SoladyTest {
_limitStringLength(s);
s = string(abi.encodePacked('"', LibString.escapeJSON(s), '"'));
this.decodeString(s);
assertEq(this.parsedValue(s), s);
}
function _limitStringLength(string memory s) internal {
Expand Down

0 comments on commit 1a61274

Please sign in to comment.