Mercurial > hg > octave-lyh
changeset 8192:9a0a66f650b1
tests for int64 arithmetics
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 07 Oct 2008 15:49:03 +0200 |
parents | 9cb73236e552 |
children | 5fd507839b76 |
files | liboctave/oct-inttypes.cc |
diffstat | 1 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/oct-inttypes.cc +++ b/liboctave/oct-inttypes.cc @@ -607,6 +607,41 @@ INSTANTIATE_INTTYPE (uint64_t); +// Tests follow. + +/* + +%!assert(intmax("int64")/intmin("int64"),int64(-1)) +%!assert(intmin("int64")/int64(-1),intmax("int64")) +%!assert(int64(2**63),intmax("int64")) +%!test +%! wstate = warning("query", "Octave:int-convert-overflow"); +%! warning("on", "Octave:int-convert-overflow"); +%! fail("int64(2**63)","warning",".*") +%! warning(wstate.state, "Octave:int-convert-overflow"); +%!assert(uint64(2**64),intmax("uint64")) +%!test +%! a = 1.9*2^61; b = uint64(a); b++; assert(b > a) +%!test +%! a = -1.9*2^61; b = int64(a); b++; assert(b > a) +%!test +%! a = int64(-2**60) + 2; assert(1.25*a == (5*a)/4) +%!test +%! a = uint64(2**61) + 2; assert(1.25*a == (5*a)/4) +%!assert(int32(2**31+0.5),intmax('int32')) +%!test +%! wstate = warning("query", "Octave:int-convert-overflow"); +%! warning("on", "Octave:int-convert-overflow"); +%! fail("int32(2**31+0.5)","warning",".*") +%! warning(wstate.state, "Octave:int-convert-overflow"); +%!assert(int32(-2**31-0.5),intmin('int32')) +%!test +%! wstate = warning("query", "Octave:int-convert-overflow"); +%! warning("on", "Octave:int-convert-overflow"); +%! fail("int32(-2**31-0.5)","warning",".*") +%! warning(wstate.state, "Octave:int-convert-overflow"); +*/ + /* ;;; Local Variables: *** ;;; mode: C++ ***