Skip to content

Commit c4a0bd2

Browse files
committed
fix tests
1 parent 0a74bb6 commit c4a0bd2

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

inst/dbtable.m

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
endif
174174

175175
for idx=1:prop_idx-1
176+
177+
if isstruct(varargin{idx})
178+
error ("dbtable doesnt support columns of structs");
179+
endif
180+
176181
n = inputname(idx);
177182
if isempty(n)
178183
n = sprintf("Var%d", idx);
@@ -252,7 +257,7 @@ function disp (this)
252257
if iscell(d)
253258
d = d{1};
254259
endif
255-
if !ischar(d)
260+
if !isnumeric(d)
256261
d = num2str(d);
257262
endif
258263
w = length(d);
@@ -491,33 +496,41 @@ function summary (this)
491496
%! assert(t{1,1}, [0]);
492497
%! assert(t{1,2}, [2]);
493498
%!
494-
%! assert(t(:,:), {[0;1;3], [2;4;6]});
495-
%! assert(t(1,:), {[0], [2]});
496-
%! assert(t(1,1), [0]);
497-
%!
498499
%! t.Properties.Description = "Test data";
499500
%!
500501
%! t.Properties.VariableNames = {'V1', 'V2'};
501502
%! assert(t.V1, [0;1;3]);
502503
%! assert(t.V2, [2;4;6]);
503504

505+
%!test
506+
%! t = dbtable([0;1;3], [2;4;6]);
507+
%! assert(istable(t));
508+
%! t1 = t(:,:);
509+
%! assert(istable(t1));
510+
%! assert(size(t1), [3 2])
511+
%! assert(t1{:,:}, {[0;1;3], [2;4;6]});
512+
%!
513+
%! t1 = t(:,1);
514+
%! assert(istable(t1));
515+
%! assert(size(t1), [3 1])
516+
%! assert(t1{:,:}, [0;1;3]);
517+
%!
518+
%! t1 = t(:,2);
519+
%! assert(istable(t1));
520+
%! assert(size(t1), [3 1])
521+
%! assert(t1{:,:}, [2;4;6]);
522+
%!
523+
%! t1 = t(1,:);
524+
%! assert(istable(t1));
525+
%! assert(size(t1), [1 2])
526+
%! assert(t1{:,:}, {[0], [2]});
527+
504528
%!test
505529
%! t = dbtable([0;1;3], [2;4;6]);
506530
%! assert(size(t), [3 2]);
507531
%! tc = dbtable(t);
508532
%! assert(size(tc), [3 2]);
509533

510-
%!test
511-
%! d = struct;
512-
%! d.name = { 'Name1';'Name2'; 'Name3' };
513-
%! d.age = [ 30; 21; 17];
514-
%! d.enrolled = { 1 [] 0 };
515-
%! d.nullstr = { "S1"; []; "s3" };
516-
%! t = dbtable(d);
517-
%! assert(size(t), [3 4]);
518-
%! assert(t.Properties.VariableNames, {'name', 'age', 'enrolled', 'nullstr'});
519-
%! assert(t.age, d.age);
520-
521534
%!test
522535
%! V1 = [0;1;3];
523536
%! V2 = [2;4;6];

0 commit comments

Comments
 (0)