Python:
def run_tests():
tests = [
{"arr": [1, 2, 3, 4, 5, 6, 7, 8, 9], "target": 5, "expected": 4},
{"arr": [1, 2, 3, 4, 5], "target": 1, "expected": 0},
{"arr": [1, 2, 3, 4, 5], "target": 5, "expected": 4},
{"arr": [2, 4, 6, 8, 10], "target": 7, "expected": -1},
{"arr": [10], "target": 10, "expected": 0},
{"arr": [], "target": 3, "expected": -1},
]
for i, test in enumerate(tests, 1):
result = linear_search(test["arr"], test["target"])
assert result == test["expected"], f"Test {i} failed: Expected {test['expected']}, got {result}"
print(f"Test {i} passed.")
if __name__ == "__main__":
run_tests()