changeset 19132:c3bdd640a4dd

* gcd.cc: add more tests
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Sun, 21 Sep 2014 14:45:40 -0400
parents cbd55a4e549b
children 95c804dcc76c
files libinterp/corefcn/gcd.cc
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gcd.cc	Sun Sep 21 14:40:39 2014 -0400
+++ b/libinterp/corefcn/gcd.cc	Sun Sep 21 14:45:40 2014 -0400
@@ -525,6 +525,19 @@
 %!assert (gcd (uint64 (200), uint64 (300), uint64 (50), uint64 (35)), uint64 (5))
 %!assert (gcd (18-i, -29+3i), -3-4i)
 
+%!test
+%! p = [953 967];
+%! u = [953 + i*971, 967 + i*977];
+%! [d, k(1), k(2)] = gcd (p(1), p(2));
+%! [z, w(1), w(2)] = gcd (u(1), u(2));
+%! assert (d, 1)
+%! assert (sum (p.*k), d)
+%! assert (abs (z), sqrt (2))
+%! assert (abs (sum (u.*w)), sqrt (2))
+
+%!error <all values must be integers> gcd (1/2, 2);
+%!error <all complex parts must be integers> gcd (e + i*pi, 1);
+
 %!error gcd ()
 
 %!test