예제 #1
0
 def test_clear(self):
     orderedMap = OrderedMap()
     orderedMap.put('key', 'value')
     orderedMap.clear()
     self.assertEqual(orderedMap.size(), 0)
예제 #2
0
 def test_key_set(self):
     orderedMap = OrderedMap()
     orderedMap.put('c', 1)
     orderedMap.put('a', 2)
     orderedMap.put('b', 3)
     self.assertEqual(orderedMap.keys(), ['a', 'b', 'c'])
예제 #3
0
 def test_get(self):
     orderedMap = OrderedMap()
     orderedMap.put('key', 'value')
     self.assertEqual(orderedMap.get('key'), 'value')
예제 #4
0
 def test_contains_key(self):
     orderedMap = OrderedMap()
     orderedMap.put('key', 'value')
     self.assertTrue(orderedMap.contains('key'))
예제 #5
0
 def test_put_duplicate_key(self):
     orderedMap = OrderedMap()
     orderedMap.put('key', 'value')
     orderedMap.put('key', 'newValue')
     self.assertEqual(orderedMap.size(), 1)
예제 #6
0
 def test_put_value_type_error(self):
     orderedMap = OrderedMap()
     orderedMap.put('key', 'value')
     self.assertRaises(TypeError, orderedMap.put('k', 4))
예제 #7
0
 def test_put(self):
     orderedMap = OrderedMap()
     orderedMap.put('key', 'value')
     self.assertEqual(orderedMap.size(), 1)
예제 #8
0
 def test_is_empty(self):
     orderedMap = OrderedMap()
     self.assertTrue(orderedMap.is_empty())
예제 #9
0
 def test_size_empty_map(self):
     orderedMap = OrderedMap()
     self.assertEqual(orderedMap.size(), 0)
예제 #10
0
 def test_initiate_ordered_map(self):
     try:
         orderedMap = OrderedMap()
         print("test_constructor: PASS")
     except:
         print("test_constructor: FAIL")
예제 #11
0
        orderedMap.put('key', 'value')
        self.assertRaises(TypeError, orderedMap.put(2, 'a'))

    def test_put_value_type_error(self):
        orderedMap = OrderedMap()
        orderedMap.put('key', 'value')
        self.assertRaises(TypeError, orderedMap.put('k', 4))


    def test_get(self):
        orderedMap = OrderedMap()
        orderedMap.put('key', 'value')
        self.assertEqual(orderedMap.get('key'), 'value')

    def test_remove_key(self);
        orderedMap = OrderedMap()
        orderedMap.put('key', 'value')
        orderedMap.remove('key')
        self.assertFalse(orderedMap.size())


    def test_contains_key(self):
        orderedMap = OrderedMap()
        orderedMap.put('key', 'value')
        self.assertTrue(orderedMap.contains('key'))

    def test_clear(self):
        orderedMap = OrderedMap()
        orderedMap.put('key', 'value')
        orderedMap.clear()
        self.assertEqual(orderedMap.size(), 0)