Files
arturo/exercises/practice/flatten-array/tests/test-flatten-array.art

82 lines
2.0 KiB
Plaintext
Raw Normal View History

import.version:3.0.0 {unitt}!
2024-06-06 17:13:05 +02:00
import {src/flatten-array}!
describe "Flatten Array" [
it "empty" [
expects.be:'equal? @[
[]
flattenCollection []
]
2024-06-06 17:13:05 +02:00
]
it.skip "no nesting" [
expects.be:'equal? @[
[0 1 2]
flattenCollection [0 1 2]
]
2024-06-06 17:13:05 +02:00
]
it.skip "flattens a nested array" [
expects.be:'equal? @[
[]
flattenCollection [[[]]]
]
2024-06-06 17:13:05 +02:00
]
it.skip "flattens array with just integers present" [
expects.be:'equal? @[
[1 2 3 4 5 6 7 8]
flattenCollection [1 [2 3 4 5 6 7] 8]
]
2024-06-06 17:13:05 +02:00
]
it.skip "5 level nesting" [
expects.be:'equal? @[
[0 2 2 3 8 100 4 50 neg 2]
flattenCollection [0 2 [[2 3] 8 100 4 [[[50]]]] neg 2]
]
2024-06-06 17:13:05 +02:00
]
it.skip "6 level nesting" [
expects.be:'equal? @[
[1 2 3 4 5 6 7 8]
flattenCollection [1 [2 [[3]] [4 [[5]]] 6 7] 8]
]
2024-06-06 17:13:05 +02:00
]
it.skip "null values are omitted from the final result" [
expects.be:'equal? @[
[1 2]
flattenCollection @[1 2 null]
]
2024-06-06 17:13:05 +02:00
]
it.skip "consecutive null values at the front of the array are omitted from the final result" [
expects.be:'equal? @[
[3]
flattenCollection @[null null 3]
]
2024-06-06 17:13:05 +02:00
]
it.skip "consecutive null values in the middle of the array are omitted from the final result" [
expects.be:'equal? @[
[1 4]
flattenCollection @[1 null null 4]
]
2024-06-06 17:13:05 +02:00
]
it.skip "6 level nested array with null values" [
expects.be:'equal? @[
[0 2 2 3 8 100 2]
flattenCollection @[0 2 @[[2 3] 8 @[@[100]] null @[@[null]]] 2]
]
2024-06-06 17:13:05 +02:00
]
it.skip "all values in nested array are null" [
expects.be:'equal? @[
[]
flattenCollection @[null @[@[@[null]]] null null @[@[null null] null] null]
]
2024-06-06 17:13:05 +02:00
]
]