Skip to content

Commit

Permalink
1. Move BitWidth, NumFields, and ID setter tests to hFixedWidthType
Browse files Browse the repository at this point in the history
superclass.
2. Fix typo: schema -> type.
  • Loading branch information
kevingurney committed Aug 22, 2023
1 parent 702e9ca commit e68cfa5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 51 deletions.
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

0 comments on commit e68cfa5

Please sign in to comment.