-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_top-interview-150-26-remove-duplicates-from-sorted-array.py
27 lines (19 loc) · 2.12 KB
/
test_top-interview-150-26-remove-duplicates-from-sorted-array.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pytest
import random
from top_interview_150__26_remove_duplicates_from_sorted_array import *
# https://leetcode.com/problems/remove-duplicates-from-sorted-array
def test_solution():
"""
We may generate 100 test cases for fuzzy testing this solution via:
>>> test_cases_nums = []
>>> for test_case_number in range(100):
>>> nums = sorted([rn.randint(-100,100) for i in range(200)])
>>> unums = sorted(list(set(l)))
>>> test_cases_nums.append((nums, unums))
"""
s = Solution()
nums = [-100, -99, -99, -99, -98, -97, -95, -95, -93, -92, -90, -90, -90, -89, -89, -89, -88, -87, -86, -86, -84, -83, -82, -82, -80, -80, -77, -77, -76, -75, -73, -73, -73, -71, -68, -66, -65, -62, -62, -58, -55, -54, -53, -53, -52, -51, -50, -50, -50, -49, -48, -47, -47, -46, -44, -43, -41, -41, -37, -34, -32, -32, -31, -30, -29, -28, -23, -23, -22, -22, -20, -17, -17, -17, -14, -14, -13, -12, -12, -12, -11, -10, -10, -9, -9, -9, -9, -8, -6, -6, -5, -5, -4, -4, -4, -4, -3, -2, -1, -1, -1, 1, 2, 3, 3, 5, 7, 10, 10, 12, 12, 12, 13, 14, 17, 17, 17, 18, 19, 19, 19, 19, 22, 22, 25, 27, 29, 32, 32, 33, 35, 37, 40, 40, 41, 41, 42, 44, 46, 46, 47, 47, 48, 49, 49, 49, 50, 52, 52, 52, 53, 54, 56, 56, 56, 57, 58, 59, 59, 60, 61, 61, 62, 63, 64, 65, 66, 66, 67, 67, 69, 70, 70, 71, 72, 72, 72, 72, 73, 74, 76, 77, 77, 79, 81, 84, 85, 85, 85, 87, 87, 89, 89, 90, 91, 94, 94, 94, 95, 98]
unums = [-100, -99, -98, -97, -95, -93, -92, -90, -89, -88, -87, -86, -84, -83, -82, -80, -77, -76, -75, -73, -71, -68, -66, -65, -62, -58, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -44, -43, -41, -37, -34, -32, -31, -30, -29, -28, -23, -22, -20, -17, -14, -13, -12, -11, -10, -9, -8, -6, -5, -4, -3, -2, -1, 1, 2, 3, 5, 7, 10, 12, 13, 14, 17, 18, 19, 22, 25, 27, 29, 32, 33, 35, 37, 40, 41, 42, 44, 46, 47, 48, 49, 50, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 76, 77, 79, 81, 84, 85, 87, 89, 90, 91, 94, 95, 98]
k_correct = len(unums)
assert k_correct == s.removeDuplicates(nums)
assert unums == nums[:k]