Skip to content

Commit

Permalink
Tests for arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Oct 30, 2023
1 parent 2eb31dc commit 83ddc2c
Show file tree
Hide file tree
Showing 7 changed files with 549 additions and 9 deletions.
14 changes: 7 additions & 7 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ This folder contains test cases for the openEO processes.
- [x] arcsin - <https://github.com/Open-EO/openeo-processes/pull/476>
- [x] arctan
- [x] arctan2
- [ ] array_append
- [x] array_append - <https://github.com/Open-EO/openeo-processes/pull/478>
- [ ] array_apply
- [ ] array_concat
- [ ] array_contains
- [ ] array_create
- [ ] array_element
- [x] array_concat
- [x] array_contains
- [x] array_create
- [x] array_element
- [ ] array_filter
- [ ] array_find
- [x] array_find
- [ ] array_interpolate_linear
- [ ] array_labels
- [x] array_labels
- [x] array_modify (experimental) - could use some more tests
- [x] arsinh
- [x] artanh - <https://github.com/Open-EO/openeo-processes/pull/476>
Expand Down
181 changes: 181 additions & 0 deletions tests/array_append.json5
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
{
"tests": [
{
"arguments": {
"data": [],
"value": 0
},
"returns": [
1
]
},
{
"arguments": {
"data": [
1,
2
],
"value": null
},
"returns": [
1,
2,
null
]
},
{
"arguments": {
"data": [
Expand All @@ -13,6 +36,164 @@
2,
3
]
},
{
"arguments": {
"data": [
true,
false
],
"value": true
},
"returns": [
true,
false,
true
]
},
{
"arguments": {
"data": [
true,
false
],
"value": null
},
"returns": [
true,
false,
null
]
},
{
"arguments": {
"data": [
"a",
"b"
],
"value": "c"
},
"returns": [
"a",
"b"
"3"
],
"optional": true
},
{
"arguments": {
"data": [
null,
2
],
"value": "3"
},
"returns": [
null,
2,
"3"
],
// mixing data types is optional
"optional": true
},
{
"arguments": {
"data": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1.23
},
{
"key": "B02",
"value": 0.98
}
]
},
"value": 4.56,
"label": "B03"
},
"returns": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1.23
},
{
"key": "B02",
"value": 0.98
},
{
"key": "B03",
"value": 4.56
}
]
}
},
{
"arguments": {
"data": {
"type": "labeled-array",
"data": [
{
"key": 2,
"value": 1.23
},
{
"key": 3,
"value": 0.98
}
]
},
"value": 4.56,
"label": 5
},
"returns": {
"type": "labeled-array",
"data": [
{
"key": 2,
"value": 1.23
},
{
"key": 3,
"value": 0.98
},
{
"key": 5,
"value": 4.56
}
]
}
},
{
"arguments": {
"data": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1.23
}
]
},
"value": 4.56
},
"returns": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1.23
},
{
"key": 1,
"value": 4.56
}
]
}
}
]
}
105 changes: 105 additions & 0 deletions tests/array_concat.json5
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
{
"tests": [
{
// Adds an empty array
"arguments": {
"array1": [
1
],
"array2": []
},
"returns": [
1
]
},
{
// Adds to an empty array
"arguments": {
"array1": [],
"array2": [
1
]
},
"returns": [
1
]
},
{
// Concatenates two numerical arrays.
"arguments": {
Expand Down Expand Up @@ -34,7 +58,88 @@
"b",
1,
2
],
"optional": true
},
{
// Check that a normal array and a labeled array lead to a normal array (labels get dropped)
"arguments": {
"array1": [
1,
2
],
"array2": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 3
},
{
"key": "B02",
"value": 4
}
]
}
},
"returns": [
1,
2,
3,
4
]
},
{
// Check that a labeled arrays are supported
"arguments": {
"array1": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1
},
{
"key": "B02",
"value": 2
}
]
},
"array2": {
"type": "labeled-array",
"data": [
{
"key": "B03",
"value": 3
},
{
"key": "B04",
"value": 4
}
]
}
},
"returns": {
"type": "labeled-array",
"data": [
{
"key": "B01",
"value": 1
},
{
"key": "B02",
"value": 2
},
{
"key": "B03",
"value": 3
},
{
"key": "B04",
"value": 4
}
]
}
}
]
}
20 changes: 20 additions & 0 deletions tests/array_contains.json5
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
},
"returns": false
},
{
"arguments": {
"data": [
false,
false
],
"value": false
},
"returns": true
},
{
"arguments": {
"data": [
true,
true
],
"value": false
},
"returns": false
},
{
"arguments": {
"data": [
Expand Down
Loading

0 comments on commit 83ddc2c

Please sign in to comment.