Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions test/version_sorter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,33 @@ def test_does_not_raise_on_number_overflow

def test_handles_non_version_data
non_versions = [
"", " ", ".", "-", "ćevapčići", "The Quick Brown Fox", '!@#$%^&*()',
" ", ".", "-", "",
"ćevapčići", "The Quick Brown Fox", '!@#$%^&*()',
"<--------->", "a12a8a4a22122d01541b62193e9bdad7f5eda552", "1." * 65
]
sorted = [
"<--------->", "-", "The Quick Brown Fox",
"a12a8a4a22122d01541b62193e9bdad7f5eda552", "ćevapčići",
"", " ", ".", '!@#$%^&*()', "1." * 65
"<--------->", "-", "The Quick Brown Fox", "a12a8a4a22122d01541b62193e9bdad7f5eda552",
"ćevapčići", " ", ".", "", '!@#$%^&*()', "1." * 65
]

assert_equal sorted, VersionSorter.sort(non_versions)
end

def test_handles_non_version_data_but_not_deterministic
# NOTES:
# - This test uses the same inputs as the previous test but
# supplies them in a different order.
# - It also expects the same outputs in the same order.
# - Alas, it will fail because the sorting of non-alphanumeric
# strings is currently non-deterministic.
non_versions = [
"ćevapčići", "The Quick Brown Fox", '!@#$%^&*()',
"<--------->", "a12a8a4a22122d01541b62193e9bdad7f5eda552", "1." * 65,
" ", ".", "-", ""
]
sorted = [
"<--------->", "-", "The Quick Brown Fox", "a12a8a4a22122d01541b62193e9bdad7f5eda552",
"ćevapčići", " ", ".", "", '!@#$%^&*()', "1." * 65
]

assert_equal sorted, VersionSorter.sort(non_versions)
Expand Down