Skip to content

Commit

Permalink
1. Update arguments block type properties for TableReader and TableWr…
Browse files Browse the repository at this point in the history
…iter filename argument.

2. Add basic error tests for TableReader and TableWriter.

Co-authored-by: Sarah Gilmore <[email protected]>
  • Loading branch information
kevingurney and sgilmore10 committed Sep 18, 2023
1 parent 8953e83 commit 66744a2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion matlab/src/matlab/+arrow/+io/+csv/TableReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

function obj = TableReader(filename)
arguments
filename(1, 1) {mustBeNonmissing, mustBeNonzeroLengthText}
filename (1, 1) string {mustBeNonmissing, mustBeNonzeroLengthText}
end

args = struct(Filename=filename);
Expand Down
2 changes: 1 addition & 1 deletion matlab/src/matlab/+arrow/+io/+csv/TableWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
methods
function obj = TableWriter(filename)
arguments
filename(1, 1) {mustBeNonmissing, mustBeNonzeroLengthText}
filename (1, 1) string {mustBeNonmissing, mustBeNonzeroLengthText}
end

args = struct(Filename=filename);
Expand Down
18 changes: 17 additions & 1 deletion matlab/test/arrow/io/csv/tError.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

methods(Test)

function EmptyCsvFile(testCase)
function EmptyFile(testCase)
import arrow.io.csv.*

arrowTableWrite = arrow.table();
Expand All @@ -31,6 +31,22 @@ function EmptyCsvFile(testCase)
testCase.verifyError(fcn, "arrow:io:csv:FailedToReadTable");
end

function InvalidWriterFilenameType(testCase)
import arrow.io.csv.*
fcn = @() TableWriter(table);
testCase.verifyError(fcn, "MATLAB:validation:UnableToConvert");
fcn = @() TableWriter(["a", "b"]);
testCase.verifyError(fcn, "MATLAB:validation:IncompatibleSize");
end

function InvalidReaderFilenameType(testCase)
import arrow.io.csv.*
fcn = @() TableReader(table);
testCase.verifyError(fcn, "MATLAB:validation:UnableToConvert");
fcn = @() TableReader(["a", "b"]);
testCase.verifyError(fcn, "MATLAB:validation:IncompatibleSize");
end

end

end

0 comments on commit 66744a2

Please sign in to comment.