diff --git a/test/version_sorter_test.rb b/test/version_sorter_test.rb index 1fbf478..72da11e 100644 --- a/test/version_sorter_test.rb +++ b/test/version_sorter_test.rb @@ -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)