Rev | Line | |
---|
[694] | 1 | import unittest
|
---|
| 2 | from tudelft.utilities.immutablelist.ArrayListSet import ArrayListSet
|
---|
| 3 |
|
---|
| 4 | class ArrayListTest (unittest.TestCase) :
|
---|
| 5 |
|
---|
| 6 | def setUp(self):
|
---|
| 7 | self.set = ArrayListSet[str]()
|
---|
| 8 | self.setReverse = ArrayListSet[str]()
|
---|
| 9 |
|
---|
| 10 | self.set.append("a");
|
---|
| 11 | self.set.append("b");
|
---|
| 12 | self.setReverse.append("b");
|
---|
| 13 | self.setReverse.append("a");
|
---|
| 14 |
|
---|
| 15 | def testContains(self):
|
---|
| 16 | self.assertTrue("a" in self.set)
|
---|
| 17 | self.assertFalse("c" in self.set)
|
---|
| 18 |
|
---|
| 19 | def testEquality(self):
|
---|
| 20 | self.assertEqual(self.set, self.setReverse)
|
---|
| 21 |
|
---|
| 22 | def testHashCodeInsensitiveToOrder(self):
|
---|
| 23 | self.assertEqual(hash(self.set), hash(self.setReverse))
|
---|
| 24 |
|
---|
| 25 | def testAdd(self):
|
---|
| 26 | self.assertEqual(2, len(self.set))
|
---|
| 27 | self.set.append("a")
|
---|
| 28 | self.assertEqual(2, len(self.set))
|
---|
| 29 | self.set.append("c")
|
---|
| 30 | self.assertEqual(3, len(self.set))
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | def testRemove(self) :
|
---|
| 34 | self.assertEqual(2, len(self.set))
|
---|
| 35 | self.set.remove("a")
|
---|
| 36 | self.assertEqual(1, len(self.set))
|
---|
| 37 |
|
---|
| 38 | def testAddAt(self) :
|
---|
| 39 | self.set.insert(1, "a"); # nothing happens, a already in set.
|
---|
| 40 | self.assertEqual(2, len(self.set))
|
---|
| 41 | self.set.insert(1, "c");
|
---|
| 42 | self.assertEqual("c", self.set[1])
|
---|
| 43 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.