kevingurney commented on code in PR #38530: URL: https://github.com/apache/arrow/pull/38530#discussion_r1377984900
########## matlab/src/matlab/+arrow/+array/+internal/+list/ListTypeValidator.m: ########## @@ -0,0 +1,28 @@ +%LISTTYPEVALIDATOR Defines interface used to validate MATLAB cell arrays +%can be converted into Arrow List arrays. + +% Licensed to the Apache Software Foundation (ASF) under one or more +% contributor license agreements. See the NOTICE file distributed with +% this work for additional information regarding copyright ownership. +% The ASF licenses this file to you under the Apache License, Version +% 2.0 (the "License"); you may not use this file except in compliance +% with the License. You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +% implied. See the License for the specific language governing +% permissions and limitations under the License. + +classdef ListTypeValidator Review Comment: Since this is already in an `arrow.array.internal.list` package - should we shorten this name to `arrow.array.internal.list.Validator` (or `TypeValidator`)? ########## matlab/test/arrow/array/list/tClassTypeValidator.m: ########## @@ -0,0 +1,98 @@ +%TCLASSTYPEVALIDATOR Unit tests for arrow.array.internal.list.ClassTypeValidator + +% Licensed to the Apache Software Foundation (ASF) under one or more +% contributor license agreements. See the NOTICE file distributed with +% this work for additional information regarding copyright ownership. +% The ASF licenses this file to you under the Apache License, Version +% 2.0 (the "License"); you may not use this file except in compliance +% with the License. You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +% implied. See the License for the specific language governing +% permissions and limitations under the License. + +classdef tClassTypeValidator < matlab.unittest.TestCase + + methods (Test) + function Smoke(testCase) + import arrow.array.internal.list.ClassTypeValidator + validator = ClassTypeValidator("Sample Data"); + testCase.verifyInstanceOf(validator, "arrow.array.internal.list.ClassTypeValidator"); + end + + function ClassNameGetter(testCase) + % Verify the ClassName getter returns the expected scalar + % string. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator("Sample Data"); + testCase.verifyEqual(validator.ClassName, "string"); + end + + function ClassNameNoSetter(testCase) + % Verify ClassName property is not settable. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator(1); + fcn = @() setfield(validator, "ClassName", "duration"); + testCase.verifyError(fcn, "MATLAB:class:SetProhibited"); + end + + function validateElementNoThrow(testCase) %#ok<MANU> Review Comment: ```suggestion function ValidateElementNoThrow(testCase) %#ok<MANU> ``` ########## matlab/test/arrow/array/list/tClassTypeValidator.m: ########## @@ -0,0 +1,98 @@ +%TCLASSTYPEVALIDATOR Unit tests for arrow.array.internal.list.ClassTypeValidator + +% Licensed to the Apache Software Foundation (ASF) under one or more +% contributor license agreements. See the NOTICE file distributed with +% this work for additional information regarding copyright ownership. +% The ASF licenses this file to you under the Apache License, Version +% 2.0 (the "License"); you may not use this file except in compliance +% with the License. You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +% implied. See the License for the specific language governing +% permissions and limitations under the License. + +classdef tClassTypeValidator < matlab.unittest.TestCase + + methods (Test) + function Smoke(testCase) + import arrow.array.internal.list.ClassTypeValidator + validator = ClassTypeValidator("Sample Data"); + testCase.verifyInstanceOf(validator, "arrow.array.internal.list.ClassTypeValidator"); + end + + function ClassNameGetter(testCase) + % Verify the ClassName getter returns the expected scalar + % string. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator("Sample Data"); + testCase.verifyEqual(validator.ClassName, "string"); + end + + function ClassNameNoSetter(testCase) + % Verify ClassName property is not settable. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator(1); + fcn = @() setfield(validator, "ClassName", "duration"); + testCase.verifyError(fcn, "MATLAB:class:SetProhibited"); + end + + function validateElementNoThrow(testCase) %#ok<MANU> + % Verify validateElement does not throw an exception + % if class type of the input element matches the ClassName + % property value. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator(1); + validator.validateElement(2); + validator.validateElement([1 2 3]); + validator.validateElement([1; 2; 3; 3]); + validator.validateElement([5 6; 7 8]); + validator.validateElement(double.empty(0, 1)); + end + + function validateElementClassTypeMismatchError(testCase) Review Comment: ```suggestion function ValidateElementClassTypeMismatchError(testCase) ``` ########## matlab/test/arrow/array/list/tClassTypeValidator.m: ########## @@ -0,0 +1,98 @@ +%TCLASSTYPEVALIDATOR Unit tests for arrow.array.internal.list.ClassTypeValidator + +% Licensed to the Apache Software Foundation (ASF) under one or more +% contributor license agreements. See the NOTICE file distributed with +% this work for additional information regarding copyright ownership. +% The ASF licenses this file to you under the Apache License, Version +% 2.0 (the "License"); you may not use this file except in compliance +% with the License. You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +% implied. See the License for the specific language governing +% permissions and limitations under the License. + +classdef tClassTypeValidator < matlab.unittest.TestCase + + methods (Test) + function Smoke(testCase) + import arrow.array.internal.list.ClassTypeValidator + validator = ClassTypeValidator("Sample Data"); + testCase.verifyInstanceOf(validator, "arrow.array.internal.list.ClassTypeValidator"); + end + + function ClassNameGetter(testCase) + % Verify the ClassName getter returns the expected scalar + % string. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator("Sample Data"); + testCase.verifyEqual(validator.ClassName, "string"); + end + + function ClassNameNoSetter(testCase) + % Verify ClassName property is not settable. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator(1); + fcn = @() setfield(validator, "ClassName", "duration"); + testCase.verifyError(fcn, "MATLAB:class:SetProhibited"); + end + + function validateElementNoThrow(testCase) %#ok<MANU> + % Verify validateElement does not throw an exception + % if class type of the input element matches the ClassName + % property value. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator(1); + validator.validateElement(2); + validator.validateElement([1 2 3]); + validator.validateElement([1; 2; 3; 3]); + validator.validateElement([5 6; 7 8]); + validator.validateElement(double.empty(0, 1)); + end + + function validateElementClassTypeMismatchError(testCase) + % Verify validateElement throws an exception whose identifier + % is "arrow:array:list:ClassTypeMismatch" if the input + % element's class type does not match the ClassName property + % value. + import arrow.array.internal.list.ClassTypeValidator + + validator = ClassTypeValidator(1); Review Comment: ```suggestion % validator will expect all elements to be of type double, since "1" is a double. validator = ClassTypeValidator(1); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
