Exemple #1
0
 def test_select_empty_list(self):
     e = Enumerable([])
     result = e.select(lambda x: 'hello').to_list()
     self.assertListEqual(result, [])
Exemple #2
0
 def test_select_to_list(self):
     e = Enumerable(range(5))
     result = e.select(lambda x: x * 2).to_list()
     self.assertListEqual(result, [0, 2, 4, 6, 8])
Exemple #3
0
 def test_select_to_dict(self):
     e = Enumerable(range(1, 4))
     result = e.select(lambda x: 'a' * x).to_dict(lambda x: x,
                                                  lambda x: len(x))
     self.assertDictEqual(result, {'a': 1, 'aa': 2, 'aaa': 3})