FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Structural Testing File interpolation_search.py by snowiceheart2000 · Pull Request #142 · AllAlgorithms/python · GitHub

This repository was archived by the owner on Sep 7, 2025. It is now read-only.
/ python Public archive
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 20 additions & 0 deletions algorithms/searches/interpolation_search.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,29 @@ def __assert_sorted(collection):
raise ValueError('Collection must be sorted')
return True

import unittest
class Testinterpolation_search(unittest.TestCase):
def testMCC(self):
self.assertEqual(None, interpolation_search([2, 5, 7, 8], 12))
self.assertEqual(None, interpolation_search([2, 5, 7, 8], 0))
self.assertEqual(1, interpolation_search([2, 5, 7, 8], 5))
self.assertEqual(2, interpolation_search([3, 6, 12, 14, 17], 12))
self.assertEqual(1, interpolation_search([3, 6, 12, 14, 17], 6))


def testAllDUpath(self):
self.assertEqual(None, interpolation_search([2, 5, 7, 8], 12))
self.assertEqual(None, interpolation_search([2, 5, 7, 8], 0))
self.assertEqual(1, interpolation_search([2, 5, 7, 8], 5))
self.assertEqual(2, interpolation_search([3, 6, 12, 14, 17], 12))
self.assertEqual(1, interpolation_search([3, 6, 12, 14, 17], 6))
self.assertEqual(3, interpolation_search([5, 7, 11, 15, 19], 15))


if __name__ == '__main__':
import sys

unittest.main()

user_input = raw_input('Enter numbers separated by comma:\n').strip()
collection = [int(item) for item in user_input.split(',')]
Expand Down

Back | FazBrowse Home | New Git URL