kevingurney commented on code in PR #38533:
URL: https://github.com/apache/arrow/pull/38533#discussion_r1378074022


##########
matlab/src/matlab/+arrow/+array/+internal/+list/DatetimeValidator.m:
##########
@@ -0,0 +1,49 @@
+% 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 DatetimeValidator < arrow.array.internal.list.ClassTypeValidator
+
+    properties (GetAccess=public, SetAccess=private)
+        HasTimeZone (1, 1) logical = false

Review Comment:
   I am fine with this name, but an alternative name for this property could be 
`Zoned`, since you talk about `Zoned` and `Unzoned` `datetime`s in the code 
comments. 



##########
matlab/test/arrow/array/list/tDatetimeValidator.m:
##########
@@ -0,0 +1,182 @@
+%TDATETIMEVALIDATOR Unit tests for
+%arrow.array.internal.list.DatetimeValditor
+
+% 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 tDatetimeValidator < matlab.unittest.TestCase
+
+    methods (Test)
+        function Smoke(testCase)
+            import arrow.array.internal.list.DatetimeValidator
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            testCase.verifyInstanceOf(validator, 
"arrow.array.internal.list.DatetimeValidator");
+        end
+
+        function ClassNameGetter(testCase)
+            % Verify the ClassName getter returns the expected scalar
+            % string.
+            import arrow.array.internal.list.DatetimeValidator
+
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            testCase.verifyEqual(validator.ClassName, "datetime");
+        end
+
+        function ClassNameNoSetter(testCase)
+            % Verify ClassName property is not settable.
+            import arrow.array.internal.list.DatetimeValidator
+
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            fcn = @() setfield(validator, "ClassName", "duration");
+            testCase.verifyError(fcn, "MATLAB:class:SetProhibited");
+        end
+
+        function HasTimeZoneGetter(testCase)
+            % Verify the HasTimeZone getter returns the expected scalar
+            % logical.
+
+            import arrow.array.internal.list.DatetimeValidator
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            testCase.verifyEqual(validator.HasTimeZone, false);
+
+            validator = DatetimeValidator(datetime(2023, 10, 31, 
TimeZone="UTC"));
+            testCase.verifyEqual(validator.HasTimeZone, true);
+        end
+
+        function HasTimeZoneNoSetter(testCase)
+            % Verify HasTimeZone property is not settable.
+            import arrow.array.internal.list.DatetimeValidator
+
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            fcn = @() setfield(validator, "HasTimeZone", true);
+            testCase.verifyError(fcn, "MATLAB:class:SetProhibited");
+
+             validator = DatetimeValidator(datetime(2023, 10, 31, 
TimeZone="UTC"));
+            fcn = @() setfield(validator, "HasTimeZone", false);
+            testCase.verifyError(fcn, "MATLAB:class:SetProhibited");
+        end
+
+        function ValidateElementNoThrow(testCase) %#ok<MANU>
+            % Verify validateElement does not throw an exception if:
+            %  1. the input element is a datetime
+            %  2. its TimeZone property is '' (only if HasTimeZone = false)
+            %  3. its TimeZone property is not empty (ony if HasTimeZone = 
true).

Review Comment:
   ```suggestion
               %  3. its TimeZone property is not empty and HasTimeZone = true
   ```



##########
matlab/test/arrow/array/list/tDatetimeValidator.m:
##########
@@ -0,0 +1,182 @@
+%TDATETIMEVALIDATOR Unit tests for
+%arrow.array.internal.list.DatetimeValditor

Review Comment:
   ```suggestion
   %arrow.array.internal.list.DatetimeValidator
   ```



##########
matlab/test/arrow/array/list/tDatetimeValidator.m:
##########
@@ -0,0 +1,182 @@
+%TDATETIMEVALIDATOR Unit tests for
+%arrow.array.internal.list.DatetimeValditor
+
+% 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 tDatetimeValidator < matlab.unittest.TestCase
+
+    methods (Test)
+        function Smoke(testCase)
+            import arrow.array.internal.list.DatetimeValidator
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            testCase.verifyInstanceOf(validator, 
"arrow.array.internal.list.DatetimeValidator");
+        end
+
+        function ClassNameGetter(testCase)
+            % Verify the ClassName getter returns the expected scalar
+            % string.
+            import arrow.array.internal.list.DatetimeValidator
+
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            testCase.verifyEqual(validator.ClassName, "datetime");
+        end
+
+        function ClassNameNoSetter(testCase)
+            % Verify ClassName property is not settable.
+            import arrow.array.internal.list.DatetimeValidator
+
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            fcn = @() setfield(validator, "ClassName", "duration");
+            testCase.verifyError(fcn, "MATLAB:class:SetProhibited");
+        end
+
+        function HasTimeZoneGetter(testCase)
+            % Verify the HasTimeZone getter returns the expected scalar
+            % logical.
+
+            import arrow.array.internal.list.DatetimeValidator
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            testCase.verifyEqual(validator.HasTimeZone, false);
+
+            validator = DatetimeValidator(datetime(2023, 10, 31, 
TimeZone="UTC"));
+            testCase.verifyEqual(validator.HasTimeZone, true);
+        end
+
+        function HasTimeZoneNoSetter(testCase)
+            % Verify HasTimeZone property is not settable.
+            import arrow.array.internal.list.DatetimeValidator
+
+            validator = DatetimeValidator(datetime(2023, 10, 31));
+            fcn = @() setfield(validator, "HasTimeZone", true);
+            testCase.verifyError(fcn, "MATLAB:class:SetProhibited");
+
+             validator = DatetimeValidator(datetime(2023, 10, 31, 
TimeZone="UTC"));
+            fcn = @() setfield(validator, "HasTimeZone", false);
+            testCase.verifyError(fcn, "MATLAB:class:SetProhibited");
+        end
+
+        function ValidateElementNoThrow(testCase) %#ok<MANU>
+            % Verify validateElement does not throw an exception if:
+            %  1. the input element is a datetime
+            %  2. its TimeZone property is '' (only if HasTimeZone = false)

Review Comment:
   ```suggestion
               %  2. its TimeZone property is '' and HasTimeZone = false
   ```



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to