spark: add word counter utility with tests
This commit is contained in:
1 parent
394de5374a
commit
bea6b75eec
243 files changed
+11095
No files matched your search
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test file for array_intersection.py"""
|
||||
import sys
|
||||
sys.path.insert(0, '/root/.hermes/wizard-outputs/spark')
|
||||
from array_intersection import array_intersection
|
||||
|
||||
# Test cases
|
||||
tests = [
|
||||
([1, 2, 3, 4, 5], [3, 4, 5, 6, 7], [3, 4, 5]),
|
||||
([1, 1, 2, 2], [2, 2, 3, 3], [2]),
|
||||
([], [1, 2, 3], []),
|
||||
([1, 2, 3], [], []),
|
||||
(['a', 'b'], ['b', 'c'], ['b']),
|
||||
]
|
||||
|
||||
all_passed = True
|
||||
for arr1, arr2, expected in tests:
|
||||
result = array_intersection(arr1, arr2)
|
||||
if result != expected:
|
||||
print(f'FAIL: {arr1} ∩ {arr2} = {result}, expected {expected}')
|
||||
all_passed = False
|
||||
else:
|
||||
print(f'PASS: {arr1} ∩ {arr2} = {result}')
|
||||
|
||||
if all_passed:
|
||||
print('All tests passed!')
|
||||
sys.exit(0)
|
||||
else:
|
||||
print('Some tests failed!')
|
||||
sys.exit(1)
|
||||
Reference in new issue
Block a user