# Path: tests/search/dummies.py
# class DummyNode(object):
#     def __init__(self, value):
#         self.value = value
# 
#     def __lt__(self, other):
#         return self.value < other.value
# 
# Path: simpleai/search/utils.py
# class FifoList(deque):
#     '''List that pops from the beginning.'''
#     def pop(self):
#         return super(FifoList, self).popleft()
# 
#     def sorted(self):
#         return list(self)
# 
# class BoundedPriorityQueue(object):
#     def __init__(self, limit=None, *args):
#         self.limit = limit
#         self.queue = list()
# 
#     def __getitem__(self, val):
#         return self.queue[val]
# 
#     def __len__(self):
#         return len(self.queue)
# 
#     def append(self, x):
#         heapq.heappush(self.queue, x)
#         if self.limit and len(self.queue) > self.limit:
#             self.queue.remove(heapq.nlargest(1, self.queue)[0])
#             heapq.heapify(self.queue)
# 
#     def pop(self):
#         return heapq.heappop(self.queue)
# 
#     def extend(self, iterable):
#         for x in iterable:
#             self.append(x)
# 
#     def clear(self):
#         self.queue.clear()
# 
#     def remove(self, x):
#         self.queue.remove(x)
#         heapq.heapify(self.queue)
# 
#     def sorted(self):
#         return heapq.nsmallest(len(self.queue), self.queue)
# 
# class LifoList(deque):
#     '''List that pops from the end.'''
# 
#     def sorted(self):
#         return list(self)[::-1]
# 
# def argmax(iterable, function):
#     return _generic_arg(iterable, function, max)
# 
# def argmin(iterable, function):
#     return _generic_arg(iterable, function, min)


import unittest
from tests.search.dummies import DummyNode
from simpleai.search.utils import FifoList, BoundedPriorityQueue, LifoList, argmax, argmin
        self.f.append(3)

    def test_sorted_lifo(self):
        self.assertTrue(sorted_equals_pop(self.f))


class TestFifoList(unittest.TestCase):
    def setUp(self):
        self.f = FifoList()
        self.f.append(1)
        self.f.append(2)
        self.f.append(3)

    def test_pop_returns_first_element(self):
        self.assertEqual(self.f.pop(), 1)
        self.assertEqual(len(self.f), 2)

    def test_sorted_fifo(self):
        self.assertTrue(sorted_equals_pop(self.f))


class TestBoundedPriorityQueue(unittest.TestCase):
    def test_append_works(self):
        q = BoundedPriorityQueue()
        q.append(DummyNode(1))
        q.append(DummyNode(1))
        self.assertEqual(len(q), 2)

    def test_extend_works(self):
        q = BoundedPriorityQueue()

# Path: tests/search/dummies.py
# class DummyNode(object):
#     def __init__(self, value):
#         self.value = value
# 
#     def __lt__(self, other):
#         return self.value < other.value
# 
# Path: simpleai/search/utils.py
# class FifoList(deque):
#     '''List that pops from the beginning.'''
#     def pop(self):
#         return super(FifoList, self).popleft()
# 
#     def sorted(self):
#         return list(self)
# 
# class BoundedPriorityQueue(object):
#     def __init__(self, limit=None, *args):
#         self.limit = limit
#         self.queue = list()
# 
#     def __getitem__(self, val):
#         return self.queue[val]
# 
#     def __len__(self):
#         return len(self.queue)
# 
#     def append(self, x):
#         heapq.heappush(self.queue, x)
#         if self.limit and len(self.queue) > self.limit:
#             self.queue.remove(heapq.nlargest(1, self.queue)[0])
#             heapq.heapify(self.queue)
# 
#     def pop(self):
#         return heapq.heappop(self.queue)
# 
#     def extend(self, iterable):
#         for x in iterable:
#             self.append(x)
# 
#     def clear(self):
#         self.queue.clear()
# 
#     def remove(self, x):
#         self.queue.remove(x)
#         heapq.heapify(self.queue)
# 
#     def sorted(self):
#         return heapq.nsmallest(len(self.queue), self.queue)
# 
# class LifoList(deque):
#     '''List that pops from the end.'''
# 
#     def sorted(self):
#         return list(self)[::-1]
# 
# def argmax(iterable, function):
#     return _generic_arg(iterable, function, max)
# 
# def argmin(iterable, function):
#     return _generic_arg(iterable, function, min)


# Path: tests/search/test_utils.py
import unittest
from tests.search.dummies import DummyNode
from simpleai.search.utils import FifoList, BoundedPriorityQueue, LifoList, argmax, argmin

        self.f.append(3)

    def test_sorted_lifo(self):
        self.assertTrue(sorted_equals_pop(self.f))


class TestFifoList(unittest.TestCase):
    def setUp(self):
        self.f = FifoList()
        self.f.append(1)
        self.f.append(2)
        self.f.append(3)

    def test_pop_returns_first_element(self):
        self.assertEqual(self.f.pop(), 1)
        self.assertEqual(len(self.f), 2)

    def test_sorted_fifo(self):
        self.assertTrue(sorted_equals_pop(self.f))


class TestBoundedPriorityQueue(unittest.TestCase):
    def test_append_works(self):
        q = BoundedPriorityQueue()
        q.append(DummyNode(1))
        q.append(DummyNode(1))
        self.assertEqual(len(q), 2)

    def test_extend_works(self):
        q = BoundedPriorityQueue()

        q.extend([DummyNode(1), DummyNode(1)])