source: immutablelistpy/test/immutablelist/RangeTest.py@ 196

Last change on this file since 196 was 195, checked in by wouter, 4 years ago

preparing python version of immutablelist

File size: 1.0 KB
Line 
1from decimal import Decimal
2from immutablelist.Range import Range
3import unittest
4
5
6class RangeTest (unittest.TestCase) :
7
8 def testSmoke(self):
9 Range(Decimal('1'), Decimal('2'), Decimal('0.1'))
10
11
12 def testGet(self):
13 r=Range(Decimal('1'), Decimal('2'), Decimal('0.1'))
14 self.assertEqual(1, r.get(0))
15 self.assertEqual(Decimal('1.1'), r.get(1))
16 self.assertEqual(Decimal('2'), r.get(10))
17
18 def testSize(self):
19 r=Range(Decimal('1'), Decimal('2'), Decimal('0.1'))
20 self.assertEqual(Decimal(11), r.size())
21
22 def testIterator(self):
23 r=Range(Decimal('1'), Decimal('2'), Decimal('0.1'))
24 self.assertTrue(Decimal('1') in r)
25 self.assertTrue(Decimal('2') in r)
26 self.assertFalse(Decimal('0.9') in r)
27 self.assertFalse(Decimal('0.9999') in r)
28 self.assertFalse(Decimal('1.22') in r)
29 self.assertFalse(Decimal('2.1') in r)
30
31 def testIterator2(self):
32 r=Range(Decimal('1'), Decimal('2'), Decimal('0.1'))
33 values=[v for v in r]
34 print(values)
35
36 def testIterator3(self):
37 r=Range(Decimal(900),Decimal(1800),Decimal(300))
38
Note: See TracBrowser for help on using the repository browser.