]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/matlab/test/tfeathermex.m
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / matlab / test / tfeathermex.m
1 classdef tfeathermex < matlab.unittest.TestCase
2 % Tests for MATLAB featherreadmex and featherwritemex.
3
4 % Licensed to the Apache Software Foundation (ASF) under one or more
5 % contributor license agreements. See the NOTICE file distributed with
6 % this work for additional information regarding copyright ownership.
7 % The ASF licenses this file to you under the Apache License, Version
8 % 2.0 (the "License"); you may not use this file except in compliance
9 % with the License. You may obtain a copy of the License at
10 %
11 % http://www.apache.org/licenses/LICENSE-2.0
12 %
13 % Unless required by applicable law or agreed to in writing, software
14 % distributed under the License is distributed on an "AS IS" BASIS,
15 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16 % implied. See the License for the specific language governing
17 % permissions and limitations under the License.
18
19 methods(TestClassSetup)
20
21 function addFeatherFunctionsToMATLABPath(testCase)
22 import matlab.unittest.fixtures.PathFixture
23 % Add Feather test utilities to the MATLAB path.
24 testCase.applyFixture(PathFixture('util'));
25 % Add featherread and featherwrite to the MATLAB path.
26 testCase.applyFixture(PathFixture(fullfile('..', 'src')));
27 % featherreadmex must be on the MATLAB path.
28 testCase.assertTrue(~isempty(which('featherreadmex')), ...
29 '''featherreadmex'' must be on the MATLAB path. Use ''addpath'' to add folders to the MATLAB path.');
30 % featherwritemex must be on the MATLAB path.
31 testCase.assertTrue(~isempty(which('featherwritemex')), ...
32 '''featherwritemex'' must be on to the MATLAB path. Use ''addpath'' to add folders to the MATLAB path.');
33 end
34
35 end
36
37 methods(TestMethodSetup)
38
39 function setupTempWorkingDirectory(testCase)
40 import matlab.unittest.fixtures.WorkingFolderFixture;
41 testCase.applyFixture(WorkingFolderFixture);
42 end
43
44 end
45
46 methods(Test)
47
48 function NumericDatatypesNulls(testCase)
49 filename = fullfile(pwd, 'temp.feather');
50
51 [expectedVariables, expectedMetadata] = createVariablesAndMetadataStructs();
52 [actualVariables, ~] = featherMEXRoundTrip(filename, expectedVariables, expectedMetadata);
53 testCase.verifyEqual([actualVariables.Valid], [expectedVariables.Valid]);
54 end
55
56 function InvalidMATLABTableVariableNames(testCase)
57 filename = fullfile(pwd, 'temp.feather');
58
59 % Create a table with an invalid MATLAB table variable name.
60 invalidVariable = mlarrow.util.createVariableStruct('double', 1, true, '@');
61 validVariable = mlarrow.util.createVariableStruct('double', 1, true, 'Valid');
62 variables = [invalidVariable, validVariable];
63 metadata = mlarrow.util.createMetadataStruct(1, 2);
64 featherwritemex(filename, variables, metadata);
65 t = featherread(filename);
66
67 testCase.verifyEqual(t.Properties.VariableNames{1}, 'x_');
68 testCase.verifyEqual(t.Properties.VariableNames{2}, 'Valid');
69
70 testCase.verifyEqual(t.Properties.VariableDescriptions{1}, 'Original variable name: ''@''');
71 testCase.verifyEqual(t.Properties.VariableDescriptions{2}, '');
72 end
73
74 end
75
76 end