lilypond-0.1.55
[lilypond.git] / flowertest / rattest.cc
blob64cc51e5f46dc4fb9a9c4ffc172c26cd0bc27901
1 #include <iostream.h>
2 #include "rational.hh"
3 #include "flower-test.hh"
4 #include "string.hh"
7 #define EXP_PRINT(a) #a << ": " << (a) << "\n"
9 void
10 rattest ()
12 Rational r (1,4);
13 Rational q(1,2);
14 Rational s(6,4);
15 Rational i;
16 i.set_infinite (1);
18 cout << r << " " << s << " " << q << "\n";
19 cout << r + q << " " << (s * q + s) << " " << (q / r) << "\n";
20 cout << i;
21 cout << "inf * r" << i * r << "inf * inf " << i * i << "inf + r" << i + r;
22 cout << EXP_PRINT(-i);
23 cout << EXP_PRINT(i >? -i) << EXP_PRINT(i >? r);
24 cout << EXP_PRINT(i <? r) ;
25 Rational one(1);
26 cout << EXP_PRINT(one/Rational (4));
27 cout << EXP_PRINT(one + one/Rational (4));
28 Rational nul (0,1);
29 Rational kwart (1,4);
30 nul += kwart;
31 cout << EXP_PRINT(nul);
32 nul -= Rational (2) * kwart;
33 cout << EXP_PRINT(nul);
35 cout << EXP_PRINT(Rational (1,128) + Rational (1919,128));
39 ADD_TEST (rattest);