Skip to content

Commit 7b1bd05

Browse files
committed
chore: update file name
1 parent 70cb72b commit 7b1bd05

3 files changed

Lines changed: 76 additions & 20 deletions

File tree

.gas-snapshot

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
IntArrayLibCoverage:testAddEachBy() (gas: 11007)
2-
IntArrayLibCoverage:testAppend() (gas: 15901)
1+
IntArrayLibCoverage:testAddEachBy() (gas: 10985)
2+
IntArrayLibCoverage:testAppend() (gas: 15857)
33
IntArrayLibCoverage:testArgSort() (gas: 17564)
4-
IntArrayLibCoverage:testConcat() (gas: 14329)
5-
IntArrayLibCoverage:testDot() (gas: 11328)
6-
IntArrayLibCoverage:testDotUintArr() (gas: 11403)
7-
IntArrayLibCoverage:testIndexOf() (gas: 11570)
8-
IntArrayLibCoverage:testIndexSelector() (gas: 23513)
9-
IntArrayLibCoverage:testMax() (gas: 8076)
10-
IntArrayLibCoverage:testMaximum() (gas: 10721)
4+
IntArrayLibCoverage:testConcat() (gas: 14352)
5+
IntArrayLibCoverage:testDot() (gas: 11371)
6+
IntArrayLibCoverage:testDotUintArr() (gas: 11446)
7+
IntArrayLibCoverage:testFill() (gas: 9344)
8+
IntArrayLibCoverage:testIndexOf() (gas: 11658)
9+
IntArrayLibCoverage:testIndexSelector() (gas: 23403)
10+
IntArrayLibCoverage:testMax() (gas: 8121)
11+
IntArrayLibCoverage:testMaximum() (gas: 10744)
1112
IntArrayLibCoverage:testMin() (gas: 8158)
12-
IntArrayLibCoverage:testMinWithIndex() (gas: 8399)
13-
IntArrayLibCoverage:testPopulate() (gas: 11895)
14-
IntArrayLibCoverage:testQuickSort() (gas: 12590)
15-
IntArrayLibCoverage:testQuickSortPart1() (gas: 10845)
16-
IntArrayLibCoverage:testQuickSortPart2() (gas: 10823)
17-
IntArrayLibCoverage:testQuickSortWithIdxs() (gas: 15042)
18-
IntArrayLibCoverage:testRemove() (gas: 10194)
13+
IntArrayLibCoverage:testMin2() (gas: 8085)
14+
IntArrayLibCoverage:testMinWithIndex() (gas: 8377)
15+
IntArrayLibCoverage:testPopulate() (gas: 11873)
16+
IntArrayLibCoverage:testQuickSort() (gas: 12568)
17+
IntArrayLibCoverage:testQuickSortPart1() (gas: 10823)
18+
IntArrayLibCoverage:testQuickSortPart2() (gas: 10801)
19+
IntArrayLibCoverage:testQuickSortWithIdxs() (gas: 15139)
20+
IntArrayLibCoverage:testRemove() (gas: 14154)
1921
IntArrayLibCoverage:testSort() (gas: 13621)
20-
IntArrayLibCoverage:testSubEachBy() (gas: 11018)
21-
IntArrayLibCoverage:testSum() (gas: 8577)
22+
IntArrayLibCoverage:testSortByIndex() (gas: 12413)
23+
IntArrayLibCoverage:testSubEachBy() (gas: 10996)
24+
IntArrayLibCoverage:testSum() (gas: 8600)
2225
IntArrayLibCoverage:tester():(address) (gas: 2392)
2326
UintArrayLibCoverage:testAppend() (gas: 15955)
2427
UintArrayLibCoverage:testArgSort() (gas: 17137)

src/test/forge-coverage/IntArrayLib.t.sol

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ contract IntArrayLibTester {
7676
return y;
7777
}
7878

79+
function fill(int256[] memory x, int256 v) external pure returns (int256[] memory) {
80+
IntArrayLib.fill(x, v);
81+
return x;
82+
}
83+
84+
function sortByIndexes(int256[] memory x, uint256[] memory indexes) external pure returns (int256[] memory) {
85+
int256[] memory y = IntArrayLib.sortByIndexes(x, indexes);
86+
return y;
87+
}
88+
7989
function concat(int256[] memory a, int256[] memory b) external pure returns (int256[] memory) {
8090
int256[] memory y = IntArrayLib.concat(a, b);
8191
return y;
@@ -160,6 +170,16 @@ contract IntArrayLibCoverage is Test {
160170
assertEq(tester.min(arr), -3);
161171
}
162172

173+
function testMin2() public {
174+
int256[] memory arr = new int256[](5);
175+
arr[0] = 100;
176+
arr[1] = 200;
177+
arr[2] = type(int256).min;
178+
arr[3] = 300;
179+
arr[4] = type(int256).min;
180+
assertEq(tester.min(arr), type(int256).min);
181+
}
182+
163183
function testMinWithIndex() public {
164184
int256[] memory arr = _getDefaultArray();
165185
(int256 min_, uint256 idx) = tester.minWithIndex(arr);
@@ -175,9 +195,15 @@ contract IntArrayLibCoverage is Test {
175195

176196
function testRemove() public {
177197
int256[] memory arr = _getDefaultArray();
178-
int256[] memory removed = tester.remove(arr, 0);
179-
assertEq(removed[0], 5);
198+
int256[] memory removed = tester.remove(arr, 1);
199+
assertEq(removed[0], 1);
200+
assertEq(removed[1], -2);
180201
assertEq(removed.length, 4);
202+
203+
// remove index 5: unchange
204+
int256[] memory removed2 = tester.remove(arr, 5);
205+
assertEq(removed2[4], -3);
206+
assertEq(removed2.length, 5);
181207
}
182208

183209
function testIndexOf() public {
@@ -209,6 +235,25 @@ contract IntArrayLibCoverage is Test {
209235
assertEq(indexes[4], 1);
210236
}
211237

238+
function testSortByIndex() public {
239+
// default [1, 5, -2, 4, -3]
240+
int256[] memory arr = _getDefaultArray();
241+
242+
uint256[] memory idxs = new uint256[](5);
243+
idxs[0] = 1; // first element is arr[1] = 5
244+
idxs[1] = 3; // second element is arr[3] = 4
245+
idxs[2] = 0;
246+
idxs[3] = 2;
247+
idxs[4] = 4;
248+
249+
int256[] memory sorted = tester.sortByIndexes(arr, idxs);
250+
assertEq(sorted[0], 5);
251+
assertEq(sorted[1], 4);
252+
assertEq(sorted[2], 1);
253+
assertEq(sorted[3], -2);
254+
assertEq(sorted[4], -3);
255+
}
256+
212257
function testSort() public {
213258
int256[] memory arr = _getDefaultArray();
214259
arr = tester.sort(arr);
@@ -297,6 +342,14 @@ contract IntArrayLibCoverage is Test {
297342
assertEq(newArr[4], newArr[9]);
298343
}
299344

345+
function testFill() public {
346+
int256[] memory empty = new int256[](5);
347+
348+
int256[] memory newArr = tester.fill(empty, 77);
349+
assertEq(newArr[0], 77);
350+
assertEq(newArr[4], 77);
351+
}
352+
300353
function testPopulate() public {
301354
int256[] memory empty = new int256[](5);
302355
int256[] memory arr = _getDefaultArray();
File renamed without changes.

0 commit comments

Comments
 (0)