Mercurial > octave-nkf
diff scripts/miscellaneous/swapbytes.m @ 12847:619c1895e3e0
codesprint: Add tests for swapbytes.m
* swapbytes.m: Add 1 test and 2 input validation checks.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 16 Jul 2011 15:31:26 -0700 |
parents | d0b799dafede |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/scripts/miscellaneous/swapbytes.m Sat Jul 16 18:27:56 2011 -0400 +++ b/scripts/miscellaneous/swapbytes.m Sat Jul 16 15:31:26 2011 -0700 @@ -32,6 +32,7 @@ ## @end deftypefn function y = swapbytes (x) + if (nargin != 1) print_usage (); endif @@ -53,4 +54,11 @@ y = reshape (typecast (reshape (typecast (x(:), "uint8"), nb, numel (x)) ([nb : -1 : 1], :) (:), clx), size(x)); endif + endfunction + + +%!assert (double (swapbytes (uint16 (1:4))), [256 512 768 1024]) +%!error (swapbytes ()) +%!error (swapbytes (1, 2)) +