From 4903c53c1466b39425f349e0831a6a737dc96580 Mon Sep 17 00:00:00 2001 From: Sarah Gilmore Date: Fri, 24 May 2024 11:43:14 -0400 Subject: [PATCH] Add positive test cases to tRoundTripRecordBatch.m --- matlab/test/arrow/c/tRoundTripRecordBatch.m | 52 +++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/matlab/test/arrow/c/tRoundTripRecordBatch.m b/matlab/test/arrow/c/tRoundTripRecordBatch.m index 15a0875ea1e20..a8d2eae2efbcd 100644 --- a/matlab/test/arrow/c/tRoundTripRecordBatch.m +++ b/matlab/test/arrow/c/tRoundTripRecordBatch.m @@ -18,11 +18,57 @@ classdef tRoundTripRecordBatch < matlab.unittest.TestCase methods (Test) - % Test methods + function ZeroColumnRecordBatch(testCase) + expected = arrow.recordBatch(table()); + + cArray = arrow.c.Array(); + cSchema = arrow.c.Schema(); + expected.export(cArray.Address, cSchema.Address); + actual = arrow.tabular.RecordBatch.import(cArray, cSchema); - function unimplementedTest(testCase) - testCase.verifyFail("Unimplemented test"); + testCase.verifyEqual(actual, expected); end + + function ZeroRowRecordBatch(testCase) + doubleArray = arrow.array([]); + stringArray = arrow.array(string.empty(0, 0)); + expected = arrow.tabular.RecordBatch.fromArrays(doubleArray, stringArray); + + cArray = arrow.c.Array(); + cSchema = arrow.c.Schema(); + expected.export(cArray.Address, cSchema.Address); + actual = arrow.tabular.RecordBatch.import(cArray, cSchema); + + testCase.verifyEqual(actual, expected); + end + + function OneRowRecordBatch(testCase) + varNames = ["Col1" "Col2" "Col3"]; + t = table(1, "A", false, VariableNames=varNames); + expected = arrow.recordBatch(t); + + cArray = arrow.c.Array(); + cSchema = arrow.c.Schema(); + expected.export(cArray.Address, cSchema.Address); + actual = arrow.tabular.RecordBatch.import(cArray, cSchema); + + testCase.verifyEqual(actual, expected); + end + + function MultiRowRecordBatch(testCase) + varNames = ["Col1" "Col2" "Col3"]; + t = table((1:3)', ["A"; "B"; "C"], [false; true; false],... + VariableNames=varNames); + expected = arrow.recordBatch(t); + + cArray = arrow.c.Array(); + cSchema = arrow.c.Schema(); + expected.export(cArray.Address, cSchema.Address); + actual = arrow.tabular.RecordBatch.import(cArray, cSchema); + + testCase.verifyEqual(actual, expected); + end + end end \ No newline at end of file