]> git.donarmstrong.com Git - lilypond.git/blob - flower/test/rattest.cc
release: 0.1.52
[lilypond.git] / flower / test / rattest.cc
1 #include <iostream.h>
2 #include "rational.hh"
3 #include "flower-test.hh"
4 #include "string.hh"
5
6
7 #define EXP_PRINT(a) #a << ": " << (a) << "\n"
8
9 void
10 rattest ()
11 {
12   Rational r (1,4);
13   Rational q(1,2);
14   Rational s(6,4);
15   Rational i;
16   i.set_infinite (1);
17
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);
34
35   cout << EXP_PRINT(Rational (1,128)  + Rational (1919,128));
36
37 }
38
39 ADD_TEST (rattest);