# Path: search/binary_search.py
# def binary_search(array, target_value):
#     left = 0
#     right = len(array) - 1
# 
#     while left <= right:
#         mid = (left + right) / 2
#         if array[mid] == target_value:
#             return mid
# 
#         if array[mid] > target_value:
#             right = mid - 1
#         elif array[mid] < target_value:
#             left = mid + 1
# 
#     return right + 1


from unittest.case import TestCase
from search.binary_search import binary_search


class BinarySearchTest(TestCase):

    def generate_array(self):
        return [1, 2, 12, 16, 25, 33, 57]

    def test_exists1(self):
        array = self.generate_array()

# Path: search/binary_search.py
# def binary_search(array, target_value):
#     left = 0
#     right = len(array) - 1
# 
#     while left <= right:
#         mid = (left + right) / 2
#         if array[mid] == target_value:
#             return mid
# 
#         if array[mid] > target_value:
#             right = mid - 1
#         elif array[mid] < target_value:
#             left = mid + 1
# 
#     return right + 1


# Path: tests/search/binary_search_test.py
from unittest.case import TestCase
from search.binary_search import binary_search



class BinarySearchTest(TestCase):

    def generate_array(self):
        return [1, 2, 12, 16, 25, 33, 57]

    def test_exists1(self):
        array = self.generate_array()

        ind = binary_search(array, 12)