Skip to content

Commit

Permalink
title abbreviations: add semantic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRTA committed Dec 16, 2022
1 parent aa0187b commit e723da3
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion crates/livesplit-title-abbreviations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ mod tests {
use alloc::boxed::Box;
use alloc::vec;

// The tests using actual game titles can be thrown out or edited if any
// major changes need to be made to the abbreviation algorithm. Do not
// hesitate to remove them if they are getting in the way of actual
// improvements.
//
// They exist purely as another measure to prevent accidental breakage.
#[test]
fn burnout_3() {
let abbreviations = abbreviate("Burnout 3: Takedown");
Expand Down Expand Up @@ -276,15 +282,37 @@ mod tests {

assert_eq!(abbreviations, expected);
}

#[test]
#[rustfmt::skip]
fn sm64() {
let abbreviations = abbreviate("Super Mario 64");

let expected = vec![
Box::from("SM64"),
Box::from("Super Mario 64")
Box::from("Super Mario 64"),
];

assert_eq!(abbreviations, expected);
}

#[test]
fn contains_original_title() {
let abbreviations = abbreviate("test title: the game");
assert!(abbreviations.contains(&Box::from("test title: the game")));
}

#[test]
fn removes_parens() {
let abbreviations = abbreviate("test title (the game)");
assert!(abbreviations.contains(&Box::from("test title")));
}

#[test]
fn original_title_is_last() {
let abbreviations = abbreviate("test title: the game");
let last = abbreviations.last().unwrap();

assert_eq!("test title: the game", last.as_ref())
}
}

0 comments on commit e723da3

Please sign in to comment.