summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authoru9g <git@u9g.dev>2022-02-26 00:37:49 -0500
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-02-27 02:48:32 +0330
commit99425c5adc38793c53b76094bea9840fafa64a18 (patch)
treefd2a03cacf97e17cba956d9e199ff386060856c7 /Userland
parent6c35419236cdba84d4d166db4b5de122af967bd0 (diff)
downloadserenity-99425c5adc38793c53b76094bea9840fafa64a18.zip
Spreadsheet: Add max(If)/min(If) function for ranges
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/Spreadsheet/Tests/free-functions.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/Tests/free-functions.js b/Userland/Applications/Spreadsheet/Tests/free-functions.js
index 80cc1b59f7..dbc7de1220 100644
--- a/Userland/Applications/Spreadsheet/Tests/free-functions.js
+++ b/Userland/Applications/Spreadsheet/Tests/free-functions.js
@@ -73,6 +73,7 @@ describe("Statistics", () => {
sheet.makeCurrent();
for (let i = 0; i < 10; ++i) sheet.setCell("A", i, `${i}`);
+ for (let i = 0; i < 10; ++i) sheet.setCell("B", i, `${i * i}`);
test("sum", () => {
expect(sum).toBeDefined();
@@ -104,6 +105,26 @@ describe("Statistics", () => {
expect(averageIf(x => !Number.isNaN(x), R`A0:A10`)).toEqual(4.5);
});
+ test("minIf", () => {
+ expect(minIf).toBeDefined();
+ expect(minIf(x => x > 25, R`B0:B9`)).toEqual(36);
+ });
+
+ test("min", () => {
+ expect(min).toBeDefined();
+ expect(min(R`B0:B9`)).toEqual(0);
+ });
+
+ test("maxIf", () => {
+ expect(maxIf).toBeDefined();
+ expect(maxIf(x => x > 25, R`B0:B9`)).toEqual(81);
+ });
+
+ test("max", () => {
+ expect(max).toBeDefined();
+ expect(max(R`B0:B9`)).toEqual(81);
+ });
+
test("median", () => {
expect(median).toBeDefined();
expect(median(R`A0:A9`)).toEqual(4.5);