use std::path::PathBuf;
use vpxtool::scores;
fn fixture(name: &str) -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/fixtures")
.join(name)
}
#[test]
fn vpreg_modern_matrix_four_entries() {
let sections = scores::vpreg::read_sections(&fixture("vpreg_modern_matrix.ini"), "TheMatrix")
.expect("section");
assert_eq!(sections.len(), 1);
assert_eq!(sections[0].header, "HIGH SCORES");
assert!(sections[0].ranked);
assert_eq!(sections[0].rows.len(), 4);
assert_eq!(sections[0].rows[0], vec!["#1", "SOM", "1154150", ""]);
assert_eq!(sections[0].rows[3], vec!["#4", "CCC", "100000", ""]);
}
#[test]
fn vpreg_modern_volkan_score_only_no_names() {
let sections =
scores::vpreg::read_sections(&fixture("vpreg_modern_volkan_no_names.ini"), "volkan")
.expect("section");
assert_eq!(sections[0].rows.len(), 12);
assert_eq!(sections[0].rows[0], vec!["#1", "", "20000", ""]);
assert_eq!(sections[0].rows[11], vec!["#12", "", "50000", ""]);
}
#[test]
fn vpreg_modern_lochness_single_entry_unranked() {
let sections = scores::vpreg::read_sections(
&fixture("vpreg_modern_lochness_single_entry.ini"),
"Lochness",
)
.expect("section");
assert_eq!(sections.len(), 1);
assert!(!sections[0].ranked);
assert_eq!(sections[0].header, "LOCHNESS");
assert_eq!(sections[0].rows.len(), 1);
}
#[test]
fn vpreg_modern_name_before_n_van_halen() {
let sections = scores::vpreg::read_sections(
&fixture("vpreg_modern_name_before_n.ini"),
"musictableVAN HALEN",
)
.expect("section");
assert_eq!(sections.len(), 1);
assert_eq!(sections[0].rows.len(), 4);
assert_eq!(sections[0].rows[0], vec!["#0", "BRIAN", "40000000", ""]);
assert_eq!(sections[0].rows[3], vec!["#3", "RANDY", "25000000", ""]);
}
#[test]
fn vpreg_legacy_abracadabra_lowercase() {
let sections =
scores::vpreg::read_sections(&fixture("vpreg_legacy_abracadabra.ini"), "Abra_Ca_Dabra")
.expect("section");
assert_eq!(sections.len(), 1);
assert!(!sections[0].ranked);
assert_eq!(sections[0].header, "ABRA_CA_DABRA");
assert_eq!(sections[0].rows[0], vec!["HIGH SCORE", "DOG", "10000", ""]);
}
#[test]
fn vpreg_legacy_a_go_go_uppercase() {
let sections =
scores::vpreg::read_sections(&fixture("vpreg_legacy_a_go_go_uppercase.ini"), "A-Go-Go")
.expect("section");
assert_eq!(sections[0].rows[0], vec!["HIGH SCORE", "SOM", "719", ""]);
}
#[test]
fn glf_dark_chaos_grand_champion_split() {
let sections = scores::glf::read_sections(&fixture("glf_dark_chaos.ini")).expect("section");
assert_eq!(sections.len(), 2);
assert_eq!(sections[0].header, "GRAND CHAMPION");
assert!(!sections[0].ranked);
assert_eq!(sections[0].rows[0][1], "DAN");
assert_eq!(sections[0].rows[0][2], "9000000");
assert_eq!(sections[1].header, "HIGH SCORES");
assert!(sections[1].ranked);
assert_eq!(sections[1].rows.len(), 3);
}
#[test]
fn emhs_5plus5_carnaval() {
let sections =
scores::emhs::read_sections(&fixture("emhs_5plus5_carnaval.txt")).expect("section");
assert_eq!(sections[0].header, "HIGH SCORES");
assert!(sections[0].ranked);
assert_eq!(sections[0].rows.len(), 5);
assert_eq!(sections[0].rows[0], vec!["#1", "AAA", "95510", ""]);
assert_eq!(sections[0].rows[4], vec!["#5", "BBB", "51000", ""]);
}
#[test]
fn emhs_5plus5_8ball_with_six_header_bytes() {
let sections = scores::emhs::read_sections(&fixture("emhs_5plus5_8ball.txt")).expect("section");
assert_eq!(sections[0].rows.len(), 5);
assert_eq!(sections[0].rows[0], vec!["#1", "AAA", "5000", ""]);
assert_eq!(sections[0].rows[4], vec!["#5", "BBB", "2500", ""]);
}
#[test]
fn emhs_5plus5_roller_coaster_with_trailing_bytes() {
let sections =
scores::emhs::read_sections(&fixture("emhs_5plus5_roller_coaster.txt")).expect("section");
assert_eq!(sections[0].rows.len(), 5);
assert_eq!(sections[0].rows[0], vec!["#1", "AAA", "7500", ""]);
assert_eq!(sections[0].rows[4], vec!["#5", "BBB", "5000", ""]);
}
#[test]
fn emhs_5plus5_with_long_character_names_cuphead() {
let sections =
scores::emhs::read_sections(&fixture("emhs_5plus5_long_names.txt")).expect("section");
assert_eq!(sections[0].rows.len(), 5);
assert_eq!(sections[0].rows[0], vec!["#1", "CUPHEAD", "75000", ""]);
assert_eq!(sections[0].rows[3], vec!["#4", "KINGDICE", "55000", ""]);
}
#[test]
fn emhs_single_2in1() {
let sections = scores::emhs::read_sections(&fixture("emhs_single_2in1.txt")).expect("section");
assert_eq!(sections.len(), 1);
assert_eq!(sections[0].header, "HIGH SCORE");
assert!(!sections[0].ranked);
assert_eq!(sections[0].rows[0], vec!["HIGH SCORE", "", "1000", ""]);
}
#[test]
fn emhs_single_4queens() {
let sections =
scores::emhs::read_sections(&fixture("emhs_single_4queens.txt")).expect("section");
assert_eq!(sections[0].rows[0], vec!["HIGH SCORE", "", "50000", ""]);
}