From bedaf9811f3bb33f08bde7189f8e3e2a47405bd7 Mon Sep 17 00:00:00 2001 From: Kevin Gurney Date: Mon, 18 Sep 2023 11:41:25 -0400 Subject: [PATCH] 1. Set access for Filename property of TableWriter. 2. Add more error tests. Co-authored-by: Sarah Gilmore --- .../src/matlab/+arrow/+io/+csv/TableWriter.m | 6 +++++- matlab/test/arrow/io/csv/tError.m | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/matlab/src/matlab/+arrow/+io/+csv/TableWriter.m b/matlab/src/matlab/+arrow/+io/+csv/TableWriter.m index 79e3c3efe2f7f..eb1aafe08f545 100644 --- a/matlab/src/matlab/+arrow/+io/+csv/TableWriter.m +++ b/matlab/src/matlab/+arrow/+io/+csv/TableWriter.m @@ -20,7 +20,7 @@ Proxy end - properties(Dependent) + properties(Dependent, SetAccess=private, GetAccess=public) Filename end @@ -36,6 +36,10 @@ end function write(obj, table) + arguments + obj (1, 1) arrow.io.csv.TableWriter + table (1, 1) arrow.tabular.Table + end args = struct(TableProxyID=table.Proxy.ID); obj.Proxy.write(args); end diff --git a/matlab/test/arrow/io/csv/tError.m b/matlab/test/arrow/io/csv/tError.m index 5961616a74da3..24c420e7ba2dd 100644 --- a/matlab/test/arrow/io/csv/tError.m +++ b/matlab/test/arrow/io/csv/tError.m @@ -47,6 +47,27 @@ function InvalidReaderFilenameType(testCase) testCase.verifyError(fcn, "MATLAB:validation:IncompatibleSize"); end + function InvalidWriterWriteType(testCase) + import arrow.io.csv.* + writer = TableWriter(testCase.Filename); + fcn = @() writer.write("text"); + testCase.verifyError(fcn, "MATLAB:validation:UnableToConvert"); + end + + function WriterFilenameNoSetter(testCase) + import arrow.io.csv.* + writer = TableWriter(testCase.Filename); + fcn = @() setfield(writer, "Filename", "filename.csv"); + testCase.verifyError(fcn, "MATLAB:class:SetProhibited"); + end + + function ReaderFilenameNoSetter(testCase) + import arrow.io.csv.* + reader = TableReader(testCase.Filename); + fcn = @() setfield(reader, "Filename", "filename.csv"); + testCase.verifyError(fcn, "MATLAB:class:SetProhibited"); + end + end end \ No newline at end of file