commit 674412b43b378391f384be1859a6e49306d6c711 Author: askiiart Date: Tue Dec 17 23:01:46 2024 -0600 initial commit - has sort tests diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..90dcb94 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "alphanumeric-sort" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d67c60c5f10f11c6ee04de72b2dd98bb9d2548cbc314d22a609bfa8bd9e87e8f" + +[[package]] +name = "gregory" +version = "0.1.0" +dependencies = [ + "alphanumeric-sort", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..82fb25b --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "gregory" +version = "0.1.0" +edition = "2021" + +[dependencies] +alphanumeric-sort = "1.5.3" diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..297fa19 --- /dev/null +++ b/src/README.md @@ -0,0 +1 @@ +# Gregory diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9ae01a5 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,68 @@ +use alphanumeric_sort::sort_str_slice; + +fn main() {} + +#[test] +/// This isn't to test the program, more to test the crate works how I want, especially if I switch crates +fn test_semver_sorting() { + // copied from https://pkgs.org/download/xorg-x11-xauth + let mut versions = [ + "xorg-x11-xauth-1.1.3", + "xorg-x11-xauth-1.1.2", + "xorg-x11-xauth-1.0.9", + "xorg-x11-xauth-1.0.10", + "xorg-x11-xauth-1.1", + ]; + sort_str_slice(&mut versions); + assert_eq!( + versions, + [ + "xorg-x11-xauth-1.0.9", + "xorg-x11-xauth-1.0.10", + "xorg-x11-xauth-1.1", + "xorg-x11-xauth-1.1.2", + "xorg-x11-xauth-1.1.3" + ] + ); +} + +#[test] +fn test_date_versioning() { + // copied from https://pkgs.org/download/vpnc-script + let mut versions = [ + "vpnc-script-20230907", + "vpnc-script-20230103", + "vpnc-script-20220404", + ]; + sort_str_slice(&mut versions); + assert_eq!( + versions, + [ + "vpnc-script-20220404", + "vpnc-script-20230103", + "vpnc-script-20230907" + ] + ); +} +#[test] +fn test_git_versioning() { + // copied from aurpublish versions - https://gitlab.archlinux.org/archlinux/packaging/packages/avahi/-/commits/main + let mut versions = [ + "1:0.8+r194+g3f79789-3", + "1:0.8+r194+g3f79789-2", + "0.7+4+gd8d8c67-1", + "0.8+r189+g35bb1ba-1", + "0.8+r127+g55d783d-1", + ]; + sort_str_slice(&mut versions); + assert_eq!( + versions, + [ + "0.7+4+gd8d8c67-1", + "0.8+r127+g55d783d-1", + "0.8+r189+g35bb1ba-1", + "1:0.8+r194+g3f79789-2", + "1:0.8+r194+g3f79789-3" + ] + ); +}