Skip to content

Commit

Permalink
adds a test to make sure Tidy runs Schlinkert pruning the reversed list
Browse files Browse the repository at this point in the history
  • Loading branch information
sts10 committed Apr 24, 2023
1 parent be38459 commit 1de5d1c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/pruning_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
mod pruning_tests {
use tidy::display_information::uniquely_decodable::check_decodability;
use tidy::*;

#[test]
fn can_run_schlinkert_prune_on_reversed_list_if_it_saves_more_words() {
let list: Vec<String> = vec![
"news",
"paper",
"newspaper",
"donkey",
"newsdonkey",
"ghost",
"newsghost",
"radish",
"newsradish",
]
.iter()
.map(|w| w.to_string())
.collect();

let this_tidy_request = TidyRequest {
list: list,
should_schlinkert_prune: true,
..Default::default()
};
let new_list = tidy_list(this_tidy_request);
// If Schlinkert prune was done in forwards, only
// 5 words would be saved. But if we Schlinkert
// prune the reversed list, we save 8 words.
assert!(new_list.len() == 8);
// And now let's confirm that the new list is indeed
// uniquely decodable, at least as far as Tidy is able
// to confirm.
assert!(check_decodability(&new_list));
}
}

0 comments on commit 1de5d1c

Please sign in to comment.