diff --git a/tests/README.md b/tests/README.md index 7a35cf07..97715af7 100644 --- a/tests/README.md +++ b/tests/README.md @@ -24,7 +24,7 @@ This folder contains test cases for the openEO processes. - [x] arctan - [x] arctan2 - [x] array_append -- [ ] array_apply +- [x] array_apply - [x] array_concat - [x] array_contains - [x] array_create @@ -226,6 +226,15 @@ properties: description: An argument, can be of any type returns: description: The return value, can be of any type + required: + description: >- + A list of processes that is required for this test (except for the process provided in `id`). + This is usually required for processes that run a sub-process (callback) so that the test suite can skip tests for processes that are not supported. + type: array + items: + type: string + description: The identifier for the sub-process. + pattern: '^\w+$' delta: description: If set to a positive number the equality of the actual return value and the expected return value is checked against a delta value to circumvent problems with floating-point inaccuracy. type: number diff --git a/tests/array_apply.json5 b/tests/array_apply.json5 index 19e56861..520c8cbb 100644 --- a/tests/array_apply.json5 +++ b/tests/array_apply.json5 @@ -1,4 +1,338 @@ { "id": "array_apply", - "tests": [] -} \ No newline at end of file + "tests": [ + { + // empty array + "required": [ + "absolute" + ], + "arguments": { + "data": [], + "process": { + "process_graph": { + "absolute": { + "process_id": "absolute", + "arguments": { + "x": { + "from_argument": "x" + } + }, + "result": true + } + } + } + }, + "returns": [] + }, + { + // single math process applied to a normal array + "required": [ + "absolute" + ], + "arguments": { + "data": [ + 1, + -2, + 3.5, + -4.725, + NaN + ], + "process": { + "process_graph": { + "absolute": { + "process_id": "absolute", + "arguments": { + "x": { + "from_argument": "x" + } + }, + "result": true + } + } + } + }, + "returns": [ + 1, + 2, + 3.5, + 4.725, + NaN + ] + }, + { + // single math process applied to a normal array, with context parameter + "required": [ + "multiply" + ], + "arguments": { + "data": [ + 1, + 2.5 + ], + "process": { + "process_graph": { + "absolute": { + "process_id": "multiply", + "arguments": { + "x": { + "from_argument": "x" + }, + "y": { + "from_argument": "context" + } + }, + "result": true + } + } + }, + "context": 2.5 + }, + "returns": [ + 2.5, + 6.25 + ] + }, + { + // single comparison process with datatype change applied to a normal array + "required": [ + "gt" + ], + "arguments": { + "data": [ + 1, + -2, + 3.5, + -4.725, + NaN + ], + "process": { + "process_graph": { + "gt": { + "process_id": "gt", + "arguments": { + "x": { + "from_argument": "x" + }, + "y": 3 + }, + "result": true + } + } + } + }, + "returns": [ + false, + false, + true, + true, + false + ] + }, + { + // handle index from a normal array + "required": [ + "constant" + ], + "arguments": { + "data": [ + 1, + 2, + 3, + 4 + ], + "process": { + "process_graph": { + "const": { + "process_id": "constant", + "arguments": { + "x": { + "from_argument": "index" + } + }, + "result": true + } + } + } + }, + "returns": [ + 0, + 1, + 2, + 3 + ] + }, + { + // handle label from a labeled array + "required": [ + "constant" + ], + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": "B01", + "value": 1.23 + }, + { + "key": "B02", + "value": 0.98 + } + ] + }, + "process": { + "process_graph": { + "const": { + "process_id": "constant", + "arguments": { + "x": { + "from_argument": "label" + } + }, + "result": true + } + } + } + }, + "returns": [ + "B01", + "B02" + ] + }, + { + // handle index and value from a labeled array + "required": [ + "add" + ], + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": "B01", + "value": 1.23 + }, + { + "key": "B02", + "value": 0.98 + } + ] + }, + "process": { + "process_graph": { + "const": { + "process_id": "add", + "arguments": { + "x": { + "from_argument": "index" + }, + "y": { + "from_argument": "x" + } + }, + "result": true + } + } + } + }, + "returns": [ + 1.23, + 1.98 + ] + }, + { + // single math process applied to a labeled array + "required": [ + "subtract" + ], + "arguments": { + "data": { + "type": "labeled-array", + "data": [ + { + "key": "B01", + "value": 1.23 + }, + { + "key": "B02", + "value": 0.98 + } + ] + }, + "process": { + "process_graph": { + "const": { + "process_id": "subtract", + "arguments": { + "x": { + "from_argument": "x" + }, + "y": 1 + }, + "result": true + } + } + } + }, + "returns": { + "type": "labeled-array", + "data": [ + { + "key": "B01", + "value": 0.23 + }, + { + "key": "B02", + "value": -0.02 + } + ] + } + }, + { + // apply multiple math process to a labeled array + "required": [ + "add", + "multiply" + ], + "arguments": { + "data": [ + 1, + -2, + 3.5, + -4.725, + NaN + ], + "process": { + "process_graph": { + "add": { + "process_id": "add", + "arguments": { + "x": { + "from_argument": "x" + }, + "y": 1.5 + } + }, + "mulitply": { + "process_id": "mulitply", + "arguments": { + "x": { + "from_node": "add" + }, + "y": 2 + }, + "result": true + } + } + } + }, + "returns": [ + 5, + -1, + 10, + 6.45, + NaN + ] + } + ] +} diff --git a/tests/eq.json5 b/tests/eq.json5 index b9eea31e..50898f5f 100644 --- a/tests/eq.json5 +++ b/tests/eq.json5 @@ -97,6 +97,20 @@ }, "returns": null }, + { + "arguments": { + "x": 5, + "y": NaN + }, + "returns": false + }, + { + "arguments": { + "x": NaN, + "y": 5 + }, + "returns": false + }, { "arguments": { "x": NaN, @@ -119,4 +133,4 @@ "returns": false } ] -} \ No newline at end of file +} diff --git a/tests/gt.json5 b/tests/gt.json5 index f799f161..651401e5 100644 --- a/tests/gt.json5 +++ b/tests/gt.json5 @@ -71,6 +71,20 @@ }, "returns": null }, + { + "arguments": { + "x": 5, + "y": NaN + }, + "returns": false + }, + { + "arguments": { + "x": NaN, + "y": 5 + }, + "returns": false + }, { "arguments": { "x": NaN, diff --git a/tests/gte.json5 b/tests/gte.json5 index c513cf4f..34f58a1c 100644 --- a/tests/gte.json5 +++ b/tests/gte.json5 @@ -85,6 +85,20 @@ }, "returns": null }, + { + "arguments": { + "x": 5, + "y": NaN + }, + "returns": false + }, + { + "arguments": { + "x": NaN, + "y": 5 + }, + "returns": false + }, { "arguments": { "x": NaN, diff --git a/tests/lt.json5 b/tests/lt.json5 index e298c02b..a3601197 100644 --- a/tests/lt.json5 +++ b/tests/lt.json5 @@ -71,6 +71,20 @@ }, "returns": null }, + { + "arguments": { + "x": 5, + "y": NaN + }, + "returns": false + }, + { + "arguments": { + "x": NaN, + "y": 5 + }, + "returns": false + }, { "arguments": { "x": NaN, diff --git a/tests/lte.json5 b/tests/lte.json5 index 112735fc..b5f920c5 100644 --- a/tests/lte.json5 +++ b/tests/lte.json5 @@ -85,6 +85,20 @@ }, "returns": null }, + { + "arguments": { + "x": 5, + "y": NaN + }, + "returns": false + }, + { + "arguments": { + "x": NaN, + "y": 5 + }, + "returns": false + }, { "arguments": { "x": NaN, diff --git a/tests/neq.json5 b/tests/neq.json5 index fd4e011e..dd837847 100644 --- a/tests/neq.json5 +++ b/tests/neq.json5 @@ -97,6 +97,20 @@ }, "returns": null }, + { + "arguments": { + "x": 5, + "y": NaN + }, + "returns": true + }, + { + "arguments": { + "x": NaN, + "y": 5 + }, + "returns": true + }, { "arguments": { "x": NaN, @@ -119,4 +133,4 @@ "returns": true } ] -} \ No newline at end of file +}