initial commit - has sort tests
This commit is contained in:
commit
674412b43b
5 changed files with 93 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
16
Cargo.lock
generated
Normal file
16
Cargo.lock
generated
Normal file
|
@ -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",
|
||||||
|
]
|
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[package]
|
||||||
|
name = "gregory"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
alphanumeric-sort = "1.5.3"
|
1
src/README.md
Normal file
1
src/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Gregory
|
68
src/main.rs
Normal file
68
src/main.rs
Normal file
|
@ -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"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in a new issue