Mercurial > hg > octave-nkf
annotate test/test_range.m @ 11523:fd0a3ac60b0e
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 05:47:45 -0500 |
parents | eb63fbe60fab |
children | c3309e1ec50d |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 John W. Eaton |
7016 | 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) | |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
37 %!assert([ r ; single(z) ], single (expect)) |
6938 | 38 %!assert([ r ; logical(z) ], expect) |
7287 | 39 %!assert([ r ; sparse(z) ], sparse (expect)) |
40 %!assert([ r ; sparse(logical(z)) ], sparse (expect)) | |
6938 | 41 |
42 %!assert([ r ; int8(z) ], int8(expect)) | |
43 %!assert([ r ; int16(z) ], int16(expect)) | |
44 %!assert([ r ; int32(z) ], int32(expect)) | |
45 %!assert([ r ; int64(z) ], int64(expect)) | |
46 %!assert([ r ; uint8(z) ], uint8(expect)) | |
47 %!assert([ r ; uint16(z) ], uint16(expect)) | |
48 %!assert([ r ; uint32(z) ], uint32(expect)) | |
49 %!assert([ r ; uint64(z) ], uint64(expect)) | |
50 | |
51 | |
52 ## Test mixing non integer range with other types | |
53 | |
54 %!shared expect, r, z | |
55 %! expect = [ 1.0 1.4 1.8 2.2 2.6 3.0 | |
56 %! 0 0 0 0 0 0 ]; | |
57 %! z = zeros(1,6); | |
58 %! r = 1:0.4:3; | |
59 | |
60 %!assert([ r ; z ], expect) | |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7287
diff
changeset
|
61 %!assert([ r ; single(z) ], single (expect)) |
6938 | 62 %!assert([ r ; logical(z) ], expect) |
7287 | 63 %!assert([ r ; sparse(z) ], sparse (expect)) |
64 %!assert([ r ; sparse(logical(z)) ], sparse (expect)) | |
6938 | 65 |
66 %!assert([ r ; int8(z) ], int8(expect)) | |
67 %!assert([ r ; int16(z) ], int16(expect)) | |
68 %!assert([ r ; int32(z) ], int32(expect)) | |
69 %!assert([ r ; int64(z) ], int64(expect)) | |
70 %!assert([ r ; uint8(z) ], uint8(expect)) | |
71 %!assert([ r ; uint16(z) ], uint16(expect)) | |
72 %!assert([ r ; uint32(z) ], uint32(expect)) | |
73 %!assert([ r ; uint64(z) ], uint64(expect)) | |
74 |