diff --git a/.gas-snapshot b/.gas-snapshot index acab40ab..0625b6aa 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -195,9 +195,10 @@ LibDecimalFloatImplementationPow10Test:testExactLookups() (gas: 1281984) LibDecimalFloatImplementationPow10Test:testExactPows() (gas: 1260129) LibDecimalFloatImplementationPow10Test:testInterpolatedLookupsPower() (gas: 1282922) LibDecimalFloatImplementationPow10Test:testNoRevert(int224,int32) (runs: 5103, μ: 1258761, ~: 1259054) -LibDecimalFloatImplementationSubTest:testSubIsAdd(int256,int256,int256,int256) (runs: 5109, μ: 15686, ~: 15706) -LibDecimalFloatImplementationSubTest:testSubMinSignedValue(int256,int256,int256) (runs: 5109, μ: 14809, ~: 14755) -LibDecimalFloatImplementationSubTest:testSubOneFromMax() (gas: 5460) +LibDecimalFloatImplementationSubTest:testSubIsAdd(int256,int256,int256,int256) (runs: 5109, μ: 15665, ~: 15684) +LibDecimalFloatImplementationSubTest:testSubMinSignedValue(int256,int256,int256) (runs: 5109, μ: 14792, ~: 14735) +LibDecimalFloatImplementationSubTest:testSubOneFromMax() (gas: 6435) +LibDecimalFloatImplementationSubTest:testSubSelf(int224,int32) (runs: 5109, μ: 5346, ~: 5449) LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentExamples() (gas: 13429) LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentOverflowRescaleRevert(int256,int256,int256) (runs: 5101, μ: 14426, ~: 14395) LibDecimalFloatImplementationWithTargetExponentTest:testWithTargetExponentLargerExponentVeryLargeDiffRevert(int256,int256,int256) (runs: 5109, μ: 13307, ~: 13527) diff --git a/test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol b/test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol index 891d0dff..cc4bc1f8 100644 --- a/test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol +++ b/test/src/lib/implementation/LibDecimalFloatImplementation.sub.t.sol @@ -64,4 +64,11 @@ contract LibDecimalFloatImplementationSubTest is Test { function testSubOneFromMax() external pure { checkSub(type(int224).max, type(int32).max, 1, 0, int256(type(int224).max) * 1e8, type(int32).max - 8); } + + function testSubSelf(int224 signedCoefficientA, int32 exponentA) external pure { + (int256 signedCoefficient, int256 exponent) = + LibDecimalFloatImplementation.sub(signedCoefficientA, exponentA, signedCoefficientA, exponentA); + (exponent); + assertEq(signedCoefficient, 0, "LibDecimalFloatImplementation.sub self coefficient"); + } }