# Copyright (C) 2009, 2010 Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from collections import deque
from ranger.ext.iter_tools import *
class TestCases(unittest.TestCase):
def test_flatten(self):
def f(x):
return list(flatten(x))
self.assertEqual(
[1,2,3,4,5],
f([1,2,3,4,5]))
self.assertEqual(
[1,2,3,4,5],
f([1,[2,3],4,5]))
self.assertEqual(
[1,2,3,4,5],
f([[1,[2,3]],4,5]))
self.assertEqual(
[],
f([[[[]]]]))
self.assertEqual(
['a', 'b', 'fskldfjl'],
f(['a', ('b', 'fskldfjl')]))
self.assertEqual(
['a', 'b', 'fskldfjl'],
f([