7016
|
1 ## Copyright (C) 2007 John W. Eaton |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
|
18 |
6938
|
19 ## Test values of range |
|
20 |
|
21 %!assert(full(1:9), [ 1 2 3 4 5 6 7 8 9 ]) |
|
22 %!assert(full(1:0.4:3), [ 1.0 1.4 1.8 2.2 2.6 3.0 ]) |
|
23 %!assert(full(9:1), zeros(1,0)) |
|
24 %!assert(full(9:-1:1), [ 9 8 7 6 5 4 3 2 1 ]) |
|
25 %!assert(full(1:-1:9), zeros(1,0)) |
|
26 |
|
27 |
|
28 ## Test mixing integer range with other types |
|
29 |
|
30 %!shared expect, r, z |
|
31 %! expect = [ 1 2 3 4 5 6 7 8 9 |
|
32 %! 0 0 0 0 0 0 0 0 0 ]; |
|
33 %! z = zeros(1,9); |
|
34 %! r = 1:9; |
|
35 |
|
36 %!assert([ r ; z ], expect) |
|
37 %!assert([ r ; logical(z) ], expect) |
|
38 %!assert([ r ; sparse(z) ], expect) |
|
39 %!assert([ r ; sparse(logical(z)) ], expect) |
|
40 |
|
41 %!assert([ r ; int8(z) ], int8(expect)) |
|
42 %!assert([ r ; int16(z) ], int16(expect)) |
|
43 %!assert([ r ; int32(z) ], int32(expect)) |
|
44 %!assert([ r ; int64(z) ], int64(expect)) |
|
45 %!assert([ r ; uint8(z) ], uint8(expect)) |
|
46 %!assert([ r ; uint16(z) ], uint16(expect)) |
|
47 %!assert([ r ; uint32(z) ], uint32(expect)) |
|
48 %!assert([ r ; uint64(z) ], uint64(expect)) |
|
49 |
|
50 |
|
51 ## Test mixing non integer range with other types |
|
52 |
|
53 %!shared expect, r, z |
|
54 %! expect = [ 1.0 1.4 1.8 2.2 2.6 3.0 |
|
55 %! 0 0 0 0 0 0 ]; |
|
56 %! z = zeros(1,6); |
|
57 %! r = 1:0.4:3; |
|
58 |
|
59 %!assert([ r ; z ], expect) |
|
60 %!assert([ r ; logical(z) ], expect) |
|
61 %!assert([ r ; sparse(z) ], expect) |
|
62 %!assert([ r ; sparse(logical(z)) ], expect) |
|
63 |
|
64 %!assert([ r ; int8(z) ], int8(expect)) |
|
65 %!assert([ r ; int16(z) ], int16(expect)) |
|
66 %!assert([ r ; int32(z) ], int32(expect)) |
|
67 %!assert([ r ; int64(z) ], int64(expect)) |
|
68 %!assert([ r ; uint8(z) ], uint8(expect)) |
|
69 %!assert([ r ; uint16(z) ], uint16(expect)) |
|
70 %!assert([ r ; uint32(z) ], uint32(expect)) |
|
71 %!assert([ r ; uint64(z) ], uint64(expect)) |
|
72 |