Mercurial > octave-nkf
diff libinterp/corefcn/mappers.cc @ 18195:1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
* ov-base-sparse.cc (octave_base_sparse<T>::map):
Special case for umap_xtolower and umap_xtoupper.
* ov-float.cc (octave_float_scalar::map): Likewise.
* ov-flt-re-mat.cc (octave_float_matrix::map): Likewise.
* ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::map,
OCTAVE_VALUE_INT_SCALAR_T::map): Likewise.
* ov-re-mat.cc (octave_matrix::map): Likewise.
* ov-scalar.cc (octave_scalar::map): Likewise.
* build-sparse-tests.sh, mappers.cc: Update tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 02 Jan 2014 22:44:37 -0500 |
parents | 175b392e91fe |
children | 9ac2357f19bc |
line wrap: on
line diff
--- a/libinterp/corefcn/mappers.cc Thu Jan 02 13:23:51 2014 -0800 +++ b/libinterp/corefcn/mappers.cc Thu Jan 02 22:44:37 2014 -0500 @@ -2156,8 +2156,17 @@ %!assert (tolower ({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}}) %!assert (tolower (["ABC"; "DEF"]), ["abc"; "def"]) %!assert (tolower ({["ABC"; "DEF"]}), {["abc";"def"]}) -%!assert (tolower (68), "d") -%!assert (tolower ({[68, 68; 68, 68]}), {["dd";"dd"]}) +%!assert (tolower (68), 68) +%!assert (tolower ({[68, 68; 68, 68]}), {[68, 68; 68, 68]}) +%!test +%! classes = {@char, @double, @single, ... +%! @int8, @int16, @int32, @int64, ... +%! @uint8, @uint16, @uint32, @uint64}; +%! for i = 1:numel (classes) +%! cls = classes{i}; +%! assert (class (tolower (cls (97))), class (cls (97))); +%! assert (class (tolower (cls ([98, 99]))), class (cls ([98, 99]))); +%! endfor %!test %! a(3,3,3,3) = "D"; %! assert (tolower (a)(3,3,3,3), "d"); @@ -2207,8 +2216,17 @@ %!assert (toupper ({"abc", "def", {"ghi", {"jkl"}}}), {"ABC", "DEF", {"GHI", {"JKL"}}}) %!assert (toupper (["abc"; "def"]), ["ABC"; "DEF"]) %!assert (toupper ({["abc"; "def"]}), {["ABC";"DEF"]}) -%!assert (toupper (100), "D") -%!assert (toupper ({[100, 100; 100, 100]}), {["DD";"DD"]}) +%!assert (toupper (100), 100) +%!assert (toupper ({[100, 100; 100, 100]}), {[100, 100; 100, 100]}) +%!test +%! classes = {@char, @double, @single, ... +%! @int8, @int16, @int32, @int64, ... +%! @uint8, @uint16, @uint32, @uint64}; +%! for i = 1:numel (classes) +%! cls = classes{i}; +%! assert (class (toupper (cls (97))), class (cls (97))); +%! assert (class (toupper (cls ([98, 99]))), class (cls ([98, 99]))); +%! endfor %!test %! a(3,3,3,3) = "d"; %! assert (toupper (a)(3,3,3,3), "D");