Mercurial > hg > octave-lyh
comparison scripts/general/isvector.m @ 14039:e98140f84ae0 stable
test: Rewrite %!tests to preserve warning state.
* iscolumn.m, isrow.m, isscalar.m, isvector.m, example.m:
Rewrite %!tests to preserve warning state.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 12 Dec 2011 21:40:07 -0800 |
parents | 132c89bb44e3 |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
14038:b0cdd60db5e5 | 14039:e98140f84ae0 |
---|---|
35 sz = size (x); | 35 sz = size (x); |
36 retval = (ndims (x) == 2 && (sz(1) == 1 || sz(2) == 1)); | 36 retval = (ndims (x) == 2 && (sz(1) == 1 || sz(2) == 1)); |
37 | 37 |
38 endfunction | 38 endfunction |
39 | 39 |
40 %!assert(isvector (1)); | |
41 %!assert(isvector ([1; 2; 3])); | |
42 %!assert(!(isvector ([]))); | |
43 %!assert(!(isvector ([1, 2; 3, 4]))); | |
44 | 40 |
45 %!test | 41 %!assert (isvector (1)) |
46 %! warning ("off", "Octave:str-to-num"); | 42 %!assert (isvector ([1; 2; 3])) |
47 %! assert((isvector ("t"))); | 43 %!assert (isvector ([]), false) |
44 %!assert (isvector ([1, 2; 3, 4]), false) | |
48 | 45 |
49 %!test | 46 %!assert (isvector ("t")) |
50 %! warning ("off", "Octave:str-to-num"); | 47 %!assert (isvector ("test")) |
51 %! assert((isvector ("test"))); | 48 %!assert (isvector (["test"; "ing"]), false) |
52 | |
53 %!assert(!(isvector (["test"; "ing"]))); | |
54 | 49 |
55 %!test | 50 %!test |
56 %! s.a = 1; | 51 %! s.a = 1; |
57 %! assert((isvector (s))); | 52 %! assert (isvector (s)); |
58 | 53 |
59 %% Test input validation | 54 %% Test input validation |
60 %!error isvector (); | 55 %!error isvector () |
61 %!error isvector ([1, 2], 2); | 56 %!error isvector ([1, 2], 2) |
62 | 57 |