Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-37253: [MATLAB] Add test cases which verify that the NumFields, BitWidth, and ID properties can not be modified to hFixedWidth test class #37316

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions matlab/test/arrow/type/hFixedWidthType.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

end
25 changes: 2 additions & 23 deletions matlab/test/arrow/type/tTime32Type.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 2 additions & 23 deletions matlab/test/arrow/type/tTime64Type.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down