comparison scripts/general/bitset.m @ 17392:e09cd91168d1

Support arguments of class single in bit manipulation functions (bug #34502) * bitfcns.cc (bitop, Fbitshift): Support arguments of class single. * bitcmp.m, bitget.m, bitset.m: Support arguments of class single. Add tests.
author Mike Miller <mtmiller@ieee.org>
date Sun, 08 Sep 2013 17:55:40 -0400
parents 7d8d194f3f63
children d63878346099
comparison
equal deleted inserted replaced
17391:7d8d194f3f63 17392:e09cd91168d1
89 endfunction 89 endfunction
90 90
91 91
92 %!test 92 %!test
93 %! assert (bitset ([0, 10], [3, 3]), [4, 14]); 93 %! assert (bitset ([0, 10], [3, 3]), [4, 14]);
94 %! assert (bitset (single ([0, 10]), [3, 3]), single ([4, 14]));
94 %! pfx = {"", "u"}; 95 %! pfx = {"", "u"};
95 %! for i = 1:2 96 %! for i = 1:2
96 %! for prec = [8, 16, 32, 64] 97 %! for prec = [8, 16, 32, 64]
97 %! fcn = str2func (sprintf ("%sint%d", pfx{i}, prec)); 98 %! fcn = str2func (sprintf ("%sint%d", pfx{i}, prec));
98 %! assert (bitset (fcn ([0, 10]), [3, 3]), fcn ([4, 14])); 99 %! assert (bitset (fcn ([0, 10]), [3, 3]), fcn ([4, 14]));
106 %!error bitset (1, 2, 3, 4) 107 %!error bitset (1, 2, 3, 4)
107 %!error <A must be .= 0> bitset (-1, 2) 108 %!error <A must be .= 0> bitset (-1, 2)
108 %!error <invalid class char> bitset ("1", 2) 109 %!error <invalid class char> bitset ("1", 2)
109 %!error <N must be in the range \[1,53\]> bitset (0, 0) 110 %!error <N must be in the range \[1,53\]> bitset (0, 0)
110 %!error <N must be in the range \[1,53\]> bitset (0, 55) 111 %!error <N must be in the range \[1,53\]> bitset (0, 55)
112 %!error <N must be in the range \[1,24\]> bitset (single (0), 0)
113 %!error <N must be in the range \[1,24\]> bitset (single (0), 26)
111 %!error <N must be in the range \[1,8\]> bitset (uint8 (0), 0) 114 %!error <N must be in the range \[1,8\]> bitset (uint8 (0), 0)
112 %!error <N must be in the range \[1,8\]> bitset (uint8 (0), 9) 115 %!error <N must be in the range \[1,8\]> bitset (uint8 (0), 9)
113 %!error <N must be in the range \[1,7\]> bitset (int8 (0), 9) 116 %!error <N must be in the range \[1,7\]> bitset (int8 (0), 9)
114 %!error <N must be in the range \[1,15\]> bitset (int16 (0), 17) 117 %!error <N must be in the range \[1,15\]> bitset (int16 (0), 17)
115 %!error <N must be in the range \[1,16\]> bitset (uint16 (0), 17) 118 %!error <N must be in the range \[1,16\]> bitset (uint16 (0), 17)