From c62784d2f3c8b89e2c0a6ab2beb057bd92f2590d Mon Sep 17 00:00:00 2001 From: Sarah Gilmore Date: Thu, 2 Nov 2023 12:15:16 -0400 Subject: [PATCH] Add test for creating a list array from a cell array that just contains empty arrays --- matlab/test/arrow/array/list/tFromMATLAB.m | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/matlab/test/arrow/array/list/tFromMATLAB.m b/matlab/test/arrow/array/list/tFromMATLAB.m index fadf5f7408bae..28928325bf53a 100644 --- a/matlab/test/arrow/array/list/tFromMATLAB.m +++ b/matlab/test/arrow/array/list/tFromMATLAB.m @@ -104,6 +104,33 @@ function ListOfListOfStrings(testCase) testCase.verifyEqual(actual, expected); end + function OnlyEmptyElements(testCase) + % Create a ListArray containing only empty elements. + import arrow.array.ListArray + + emptyDuration = duration.empty(0, 0); + + C = {emptyDuration, emptyDuration, emptyDuration, emptyDuration}; + actual = ListArray.fromMATLAB(C); + + values = arrow.array(duration.empty); + offsets = arrow.array(int32([0 0 0 0 0])); + expected = ListArray.fromArrays(offsets, values); + + testCase.verifyEqual(actual, expected); + end + + function ClassTypeMismatchError(testCase) + % Verify fromMATLAB throws an error whose identifier is + % "arrow:array:list:ClassTypeMismatch" if given a cell array + % containing arrays with different class types. + import arrow.array.ListArray + + C = {1, [2 3 4], "A", 5}; + fcn = @() ListArray.fromMATLAB(C); + testCase.verifyError(fcn, "arrow:array:list:ClassTypeMismatch"); + end + end end \ No newline at end of file