From e68cfa53027d3dbb33cd6369143fc5badcb48296 Mon Sep 17 00:00:00 2001 From: Kevin Gurney Date: Tue, 22 Aug 2023 14:09:16 -0400 Subject: [PATCH] 1. Move BitWidth, NumFields, and ID setter tests to hFixedWidthType superclass. 2. Fix typo: schema -> type. --- matlab/test/arrow/type/hFixedWidthType.m | 33 ++++++++++++++++++++---- matlab/test/arrow/type/tTime32Type.m | 25 ++---------------- matlab/test/arrow/type/tTime64Type.m | 25 ++---------------- 3 files changed, 32 insertions(+), 51 deletions(-) diff --git a/matlab/test/arrow/type/hFixedWidthType.m b/matlab/test/arrow/type/hFixedWidthType.m index 308ac46011a6c..adb234bbd3f38 100644 --- a/matlab/test/arrow/type/hFixedWidthType.m +++ b/matlab/test/arrow/type/hFixedWidthType.m @@ -26,27 +26,50 @@ methods(Test) function TestClass(testCase) - % Verify ArrowType is an object of the expected class type. + % Verify ArrowType is an object of the expected class type. name = string(class(testCase.ArrowType)); testCase.verifyEqual(name, testCase.ClassName); end function TestTypeID(testCase) - % Verify ID is set to the appropriate arrow.type.ID value. + % Verify ID is set to the appropriate arrow.type.ID value. arrowType = testCase.ArrowType; testCase.verifyEqual(arrowType.ID, testCase.TypeID); end function TestBitWidth(testCase) - % Verify the BitWidth value. + % Verify the BitWidth value. arrowType = testCase.ArrowType; testCase.verifyEqual(arrowType.BitWidth, testCase.BitWidth); end function TestNumFields(testCase) - % Verify NumFields is set to 0 for primitive types. + % Verify NumFields is set to 0 for primitive types. arrowType = testCase.ArrowType; testCase.verifyEqual(arrowType.NumFields, int32(0)); end + + function TestBitWidthNoSetter(testCase) + % Verify that an error is thrown when trying to set the value + % of the BitWidth property. + arrowType = testCase.ArrowType; + testCase.verifyError(@() setfield(arrowType, "BitWidth", 64), "MATLAB:class:SetProhibited"); + end + + function TestIDNoSetter(testCase) + % Verify that an error is thrown when trying to set the value + % of the ID property. + arrowType = testCase.ArrowType; + testCase.verifyError(@() setfield(arrowType, "ID", 15), "MATLAB:class:SetProhibited"); + end + + function TestNumFieldsNoSetter(testCase) + % Verify that an error is thrown when trying to set the value + % of the NumFields property. + arrowType = testCase.ArrowType; + testCase.verifyError(@() setfield(arrowType, "NumFields", 2), "MATLAB:class:SetProhibited"); + end + end -end \ No newline at end of file + +end diff --git a/matlab/test/arrow/type/tTime32Type.m b/matlab/test/arrow/type/tTime32Type.m index 115b8dfe96b52..d778237588a27 100644 --- a/matlab/test/arrow/type/tTime32Type.m +++ b/matlab/test/arrow/type/tTime32Type.m @@ -107,29 +107,8 @@ function Display(testCase) function TimeUnitNoSetter(testCase) % Verify that an error is thrown when trying to set the value % of the TimeUnit property. - schema = arrow.time32(TimeUnit="Millisecond"); - testCase.verifyError(@() setfield(schema, "TimeUnit", "Second"), "MATLAB:class:SetProhibited"); - end - - function BitWidthNoSetter(testCase) - % Verify that an error is thrown when trying to set the value - % of the BitWidth property. - schema = arrow.time32(TimeUnit="Millisecond"); - testCase.verifyError(@() setfield(schema, "BitWidth", 64), "MATLAB:class:SetProhibited"); - end - - function IDNoSetter(testCase) - % Verify that an error is thrown when trying to set the value - % of the ID property. - schema = arrow.time32(TimeUnit="Millisecond"); - testCase.verifyError(@() setfield(schema, "ID", 15), "MATLAB:class:SetProhibited"); - end - - function NumFieldsNoSetter(testCase) - % Verify that an error is thrown when trying to set the value - % of the NumFields property. - schema = arrow.time32(TimeUnit="Millisecond"); - testCase.verifyError(@() setfield(schema, "NumFields", 2), "MATLAB:class:SetProhibited"); + type = arrow.time32(TimeUnit="Millisecond"); + testCase.verifyError(@() setfield(type, "TimeUnit", "Second"), "MATLAB:class:SetProhibited"); end function InvalidProxy(testCase) diff --git a/matlab/test/arrow/type/tTime64Type.m b/matlab/test/arrow/type/tTime64Type.m index 1b3998c5171f5..a231a76c615fd 100644 --- a/matlab/test/arrow/type/tTime64Type.m +++ b/matlab/test/arrow/type/tTime64Type.m @@ -108,29 +108,8 @@ function Display(testCase) function TimeUnitNoSetter(testCase) % Verify that an error is thrown when trying to set the value % of the TimeUnit property. - schema = arrow.time64(TimeUnit="Nanosecond"); - testCase.verifyError(@() setfield(schema, "TimeUnit", "Microsecond"), "MATLAB:class:SetProhibited"); - end - - function BitWidthNoSetter(testCase) - % Verify that an error is thrown when trying to set the value - % of the BitWidth property. - schema = arrow.time64(TimeUnit="Nanosecond"); - testCase.verifyError(@() setfield(schema, "BitWidth", 32), "MATLAB:class:SetProhibited"); - end - - function IDNoSetter(testCase) - % Verify that an error is thrown when trying to set the value - % of the ID property. - schema = arrow.time64(TimeUnit="Nanosecond"); - testCase.verifyError(@() setfield(schema, "ID", 15), "MATLAB:class:SetProhibited"); - end - - function NumFieldsNoSetter(testCase) - % Verify that an error is thrown when trying to set the value - % of the NumFields property. - schema = arrow.time64(TimeUnit="Nanosecond"); - testCase.verifyError(@() setfield(schema, "NumFields", 2), "MATLAB:class:SetProhibited"); + type = arrow.time64(TimeUnit="Nanosecond"); + testCase.verifyError(@() setfield(type, "TimeUnit", "Microsecond"), "MATLAB:class:SetProhibited"); end function InvalidProxy(testCase)