(list_length: int, part_length: int, variability: int, seed_value: int)
| 1167 | @pytest.mark.parametrize("variability", [2, 3]) |
| 1168 | @pytest.mark.parametrize("seed_value", SEED_VALUES) |
| 1169 | def test_fuzzy_sorting(list_length: int, part_length: int, variability: int, seed_value: int): |
| 1170 | seed_random_generators(seed_value) |
| 1171 | native_list = [get_random_string(variability=variability, length=part_length) for _ in range(list_length)] |
| 1172 | native_joined = ".".join(native_list) |
| 1173 | big_joined = Str(native_joined) |
| 1174 | big_list = big_joined.split(".") |
| 1175 | |
| 1176 | # Before testing sorting, validate pairwise comparator consistency |
| 1177 | def py_cmp(a: str, b: str) -> int: |
| 1178 | return -1 if a < b else (1 if a > b else 0) |
| 1179 | |
| 1180 | def sz_cmp(a: str, b: str) -> int: |
| 1181 | sa, sb = Str(a), Str(b) |
| 1182 | if sa < sb: |
| 1183 | return -1 |
| 1184 | if sa > sb: |
| 1185 | return 1 |
| 1186 | return 0 |
| 1187 | |
| 1188 | # Check every consecutive pair a[i], a[i+1] |
| 1189 | for i in range(len(native_list) - 1): |
| 1190 | a, b = native_list[i], native_list[i + 1] |
| 1191 | assert py_cmp(a, b) == sz_cmp(a, b), f"Comparator mismatch at {i}: '{a}' vs '{b}'" |
| 1192 | |
| 1193 | native_ordered = sorted(native_list) |
| 1194 | native_order = big_list.argsort() |
| 1195 | for i in range(list_length): |
| 1196 | assert native_ordered[i] == native_list[native_order[i]], "Order is wrong" |
| 1197 | assert native_ordered[i] == str(big_list[int(native_order[i])]), "Split is wrong?!" |
| 1198 | |
| 1199 | native_list.sort() |
| 1200 | big_list = big_list.sorted() |
| 1201 | |
| 1202 | assert len(native_list) == len(big_list) |
| 1203 | for native_str, big_str in zip(native_list, big_list): |
| 1204 | assert native_str == str(big_str), "Order is wrong" |
| 1205 | |
| 1206 | |
| 1207 | @pytest.mark.skipif(not pyarrow_available, reason="PyArrow is not installed") |
nothing calls this directly
no test coverage detected
searching dependent graphs…