from decimal import Decimal from immutablelist.Range import Range import unittest class RangeTest (unittest.TestCase) : def testSmoke(self): Range(Decimal('1'), Decimal('2'), Decimal('0.1')) def testGet(self): r=Range(Decimal('1'), Decimal('2'), Decimal('0.1')) self.assertEqual(1, r.get(0)) self.assertEqual(Decimal('1.1'), r.get(1)) self.assertEqual(Decimal('2'), r.get(10)) def testSize(self): r=Range(Decimal('1'), Decimal('2'), Decimal('0.1')) self.assertEqual(Decimal(11), r.size()) def testIterator(self): r=Range(Decimal('1'), Decimal('2'), Decimal('0.1')) self.assertTrue(Decimal('1') in r) self.assertTrue(Decimal('2') in r) self.assertFalse(Decimal('0.9') in r) self.assertFalse(Decimal('0.9999') in r) self.assertFalse(Decimal('1.22') in r) self.assertFalse(Decimal('2.1') in r) def testIterator2(self): r=Range(Decimal('1'), Decimal('2'), Decimal('0.1')) values=[v for v in r] print(values) def testIterator3(self): r=Range(Decimal(900),Decimal(1800),Decimal(300))