File: test_money.py

package info (click to toggle)
quantlib-swig 1.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,284 kB
  • sloc: python: 6,056; java: 1,552; cs: 774; makefile: 243; sh: 22
file content (18 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import QuantLib as ql
import operator
import unittest


class MoneyTest(unittest.TestCase):
    def test_order(self):
        ops = [operator.eq, operator.ne, operator.lt, operator.le, operator.gt, operator.ge]
        usd = lambda v: ql.Money(v, ql.USDCurrency())
        for m1 in (usd(1), usd(2)):
            for m2 in (usd(1), usd(2)):
                for op in ops:
                    self.assertEqual(op(m1,  m2), op(m1.value(), m2.value()))


if __name__ == "__main__":
    print("testing QuantLib", ql.__version__)
    unittest.main(verbosity=2)