mania & fruits test cases added

This commit is contained in:
MaxOhn
2021-01-16 11:02:06 +01:00
parent fedcbb3fa2
commit b404381cd3
6 changed files with 344 additions and 123 deletions
+5 -74
View File
@@ -333,7 +333,8 @@ mod tests {
use std::fs::File;
#[test]
fn test_single() {
#[ignore]
fn fruits_single() {
let map_id = 1972149;
let file = match File::open(format!("E:/Games/osu!/beatmaps/{}.osu", map_id)) {
Ok(file) => file,
@@ -349,79 +350,9 @@ mod tests {
Err(why) => panic!("Error while parsing map: {}", why),
};
let mods = 0;
let stars = stars(&map, mods).stars;
let result = PpCalculator::new(&map).mods(256).calculate();
println!("Stars: {} [map={} | mods={}]", stars, map_id, mods);
}
#[test]
fn test_fruits() {
let margin = 0.005;
#[rustfmt::skip]
let data = vec![
(1977380, 1 << 8, 2.0564713386286573),// HT
(1977380, 0, 2.5695489769068742), // NM
(1977380, 1 << 6, 3.589887228221038), // DT
(1977380, 1 << 4, 3.1515873669521928),// HR
(1977380, 1 << 1, 3.0035260129778396),// EZ
(1974968, 1 << 8, 1.9544305373156605),// HT
(1974968, 0, 2.521701539665241), // NM
(1974968, 1 << 6, 3.650649037957456), // DT
(1974968, 1 << 4, 3.566302788963401), // HR
(1974968, 1 << 1, 2.2029392066882654),// EZ
(2420076, 1 << 8, 4.791039358886245), // HT
(2420076, 0, 6.223136555625056), // NM
(2420076, 1 << 6, 8.908315960310958), // DT
(2420076, 1 << 4, 6.54788067620051), // HR
(2420076, 1 << 1, 6.067971540209479), // EZ
(2206596, 1 << 8, 4.767182611189798), // HT
(2206596, 0, 6.157660207091584), // NM
(2206596, 1 << 6, 8.93391286552717), // DT
(2206596, 1 << 4, 6.8639096665110735),// HR
(2206596, 1 << 1, 5.60279198088948), // EZ
// Super long juice stream towards end
// (1972149, 1 << 8, 4.671425766413811), // HT
// (1972149, 0, 6.043742871084152), // NM
// (1972149, 1 << 6, 8.469259368304225), // DT
// (1972149, 1 << 4, 6.81222485322862), // HR
// (1972149, 1 << 1, 5.289343020686747), // EZ
// Convert slider fiesta
// (1657535, 1 << 8, 3.862453635711741), // HT
// (1657535, 0, 4.792543335869686), // NM
// (1657535, 1 << 6, 6.655478646330863), // DT
// (1657535, 1 << 4, 5.259728567781568), // HR
// (1657535, 1 << 1, 4.127535166776765), // EZ
];
for (map_id, mods, expected_stars) in data {
let file = match File::open(format!("./test/{}.osu", map_id)) {
Ok(file) => file,
Err(why) => panic!("Could not open file {}.osu: {}", map_id, why),
};
let map = match Beatmap::parse(file) {
Ok(map) => map,
Err(why) => panic!("Error while parsing map {}: {}", map_id, why),
};
let stars = stars(&map, mods).stars;
assert!(
(stars - expected_stars).abs() < margin,
"Stars: {} | Expected: {} => {} margin [map {} | mods {}]",
stars,
expected_stars,
(stars - expected_stars).abs(),
map_id,
mods
);
}
println!("Stars: {}", result.stars);
println!("PP: {}", result.pp);
}
}
+5 -47
View File
@@ -82,7 +82,8 @@ mod tests {
use std::fs::File;
#[test]
fn test_single() {
#[ignore]
fn mania_single() {
let file = match File::open("E:/Games/osu!/beatmaps/1355822.osu") {
Ok(file) => file,
Err(why) => panic!("Could not open file: {}", why),
@@ -93,52 +94,9 @@ mod tests {
Err(why) => panic!("Error while parsing map: {}", why),
};
let stars = stars(&map, 256);
let result = PpCalculator::new(&map).mods(256).calculate();
println!("Stars: {}", stars);
}
#[test]
fn test_mania() {
let margin = 0.005;
#[rustfmt::skip]
let data = vec![
(1355822, 1 << 8, 2.2710870990702627), // HT
(1355822, 0, 2.7966565927524574), // NM
(1355822, 1 << 6, 3.748525363730352), // DT
(1974394, 1 << 8, 3.8736942117487256), // HT
(1974394, 0, 4.801793001581714), // NM
(1974394, 1 << 6, 6.517894438878535), // DT
(992512, 1 << 8, 5.29507262961579), // HT
(992512, 0, 6.536292432114728), // NM
(992512, 1 << 6, 8.944195050951032), // DT
];
for (map_id, mods, expected_stars) in data {
let file = match File::open(format!("./test/{}.osu", map_id)) {
Ok(file) => file,
Err(why) => panic!("Could not open file {}.osu: {}", map_id, why),
};
let map = match Beatmap::parse(file) {
Ok(map) => map,
Err(why) => panic!("Error while parsing map {}: {}", map_id, why),
};
let stars = stars(&map, mods);
assert!(
(stars - expected_stars).abs() < margin,
"Stars: {} | Expected: {} => {} margin [map {} | mods {}]",
stars,
expected_stars,
(stars - expected_stars).abs(),
map_id,
mods
);
}
println!("Stars: {}", result.stars);
println!("PP: {}", result.pp);
}
}
+210
View File
@@ -0,0 +1,210 @@
extern crate rosu_pp;
use rosu_pp::Beatmap;
use std::fs::File;
struct MapResult {
map_id: u32,
mods: u32,
stars: f32,
pp: f32,
}
#[test]
fn fruits() {
let star_margin = 0.005;
let pp_margin = 0.005;
for result in RESULTS {
let MapResult {
map_id,
mods,
stars,
pp,
} = result;
let file = match File::open(format!("./maps/{}.osu", map_id)) {
Ok(file) => file,
Err(why) => panic!("Could not open file {}.osu: {}", map_id, why),
};
let map = match Beatmap::parse(file) {
Ok(map) => map,
Err(why) => panic!("Error while parsing map {}: {}", map_id, why),
};
let result = rosu_pp::fruits::PpCalculator::new(&map)
.mods(*mods)
.calculate();
assert!(
(result.stars - stars).abs() < star_margin,
"Stars: {} | Expected: {} => {} margin [map {} | mods {}]",
result.stars,
stars,
(result.stars - stars).abs(),
map_id,
mods
);
assert!(
(result.pp - pp).abs() < pp_margin,
"PP: {} | Expected: {} => {} margin [map {} | mods {}]",
result.pp,
pp,
(result.pp - pp).abs(),
map_id,
mods
);
}
}
const RESULTS: &[MapResult] = &[
MapResult {
map_id: 1977380,
mods: 256,
stars: 2.0564713386286573,
pp: 43.49758286973066,
},
MapResult {
map_id: 1977380,
mods: 0,
stars: 2.5695489769068742,
pp: 71.54271564752817,
},
MapResult {
map_id: 1977380,
mods: 8,
stars: 2.5695489769068742,
pp: 78.29197525261374,
},
MapResult {
map_id: 1977380,
mods: 64,
stars: 3.589887228221038,
pp: 135.95326950246636,
},
MapResult {
map_id: 1977380,
mods: 16,
stars: 3.1515873669521928,
pp: 108.02360048697571,
},
MapResult {
map_id: 1977380,
mods: 2,
stars: 3.0035260129778396,
pp: 98.10009237095251,
},
// -----
MapResult {
map_id: 1974968,
mods: 256,
stars: 1.9544305373156605,
pp: 40.46051204584743,
},
MapResult {
map_id: 1974968,
mods: 0,
stars: 2.521701539665241,
pp: 64.28153872477789,
},
MapResult {
map_id: 1974968,
mods: 8,
stars: 2.521701539665241,
pp: 81.9589618740918,
},
MapResult {
map_id: 1974968,
mods: 64,
stars: 3.650649037957456,
pp: 131.5628579590708,
},
MapResult {
map_id: 1974968,
mods: 16,
stars: 3.566302788963401,
pp: 135.59111737415918,
},
MapResult {
map_id: 1974968,
mods: 2,
stars: 2.2029392066882654,
pp: 53.2211645832911,
},
// -----
MapResult {
map_id: 2420076,
mods: 256,
stars: 4.791039358886245,
pp: 226.85533170425614,
},
MapResult {
map_id: 2420076,
mods: 0,
stars: 6.223136555625056,
pp: 413.51912544400295,
},
MapResult {
map_id: 2420076,
mods: 8,
stars: 6.223136555625056,
pp: 440.3978626824246,
},
MapResult {
map_id: 2420076,
mods: 64,
stars: 8.908315960310958,
pp: 999.4280253427237,
},
MapResult {
map_id: 2420076,
mods: 16,
stars: 6.54788067620051,
pp: 466.3097817709075,
},
MapResult {
map_id: 2420076,
mods: 2,
stars: 6.067971540209479,
pp: 392.2324532647843,
},
// -----
MapResult {
map_id: 2206596,
mods: 256,
stars: 4.767182611189798,
pp: 227.40643918013868,
},
MapResult {
map_id: 2206596,
mods: 0,
stars: 6.157660207091584,
pp: 402.3258172661857,
},
MapResult {
map_id: 2206596,
mods: 8,
stars: 6.157660207091584,
pp: 434.5118711368466,
},
MapResult {
map_id: 2206596,
mods: 64,
stars: 8.93391286552717,
pp: 996.4288537655079,
},
MapResult {
map_id: 2206596,
mods: 16,
stars: 6.8639096665110735,
pp: 518.8398368985938,
},
MapResult {
map_id: 2206596,
mods: 2,
stars: 5.60279198088948,
pp: 339.327091261929,
},
];
+120
View File
@@ -0,0 +1,120 @@
extern crate rosu_pp;
use rosu_pp::Beatmap;
use std::fs::File;
struct MapResult {
map_id: u32,
mods: u32,
stars: f32,
pp: f32,
}
#[test]
fn mania() {
let star_margin = 0.001;
let pp_margin = 0.001;
for result in RESULTS {
let MapResult {
map_id,
mods,
stars,
pp,
} = result;
let file = match File::open(format!("./maps/{}.osu", map_id)) {
Ok(file) => file,
Err(why) => panic!("Could not open file {}.osu: {}", map_id, why),
};
let map = match Beatmap::parse(file) {
Ok(map) => map,
Err(why) => panic!("Error while parsing map {}: {}", map_id, why),
};
// TODO: Adjust score w.r.t. mods(?)
let result = rosu_pp::mania::PpCalculator::new(&map)
.mods(*mods)
.calculate();
assert!(
(result.stars - stars).abs() < star_margin,
"Stars: {} | Expected: {} => {} margin [map {} | mods {}]",
result.stars,
stars,
(result.stars - stars).abs(),
map_id,
mods
);
assert!(
(result.pp - pp).abs() < pp_margin,
"PP: {} | Expected: {} => {} margin [map {} | mods {}]",
result.pp,
pp,
(result.pp - pp).abs(),
map_id,
mods
);
}
}
const RESULTS: &[MapResult] = &[
MapResult {
map_id: 1355822,
mods: 256,
stars: 2.2710870990702627,
pp: 43.654638516311564,
},
MapResult {
map_id: 1355822,
mods: 0,
stars: 2.7966565927524574,
pp: 71.54271564752817,
},
MapResult {
map_id: 1355822,
mods: 64,
stars: 3.748525363730352,
pp: 140.25944202912322,
},
// -----
MapResult {
map_id: 1974394,
mods: 256,
stars: 3.8736942117487256,
pp: 155.79817482289727,
},
MapResult {
map_id: 1974394,
mods: 0,
stars: 4.801793001581714,
pp: 254.50572065264748,
},
MapResult {
map_id: 1974394,
mods: 64,
stars: 6.517894438878535,
pp: 508.4849982082652,
},
// -----
MapResult {
map_id: 992512,
mods: 256,
stars: 5.29507262961579,
pp: 317.82741466200764,
},
MapResult {
map_id: 992512,
mods: 0,
stars: 6.536292432114728,
pp: 511.72773348069154,
},
MapResult {
map_id: 992512,
mods: 64,
stars: 8.944195050951032,
pp: 1035.4596772151892,
},
];
+1
View File
@@ -0,0 +1 @@
// TODO
+3 -2
View File
@@ -33,8 +33,9 @@ fn taiko() {
Err(why) => panic!("Error while parsing map {}: {}", map_id, why),
};
let calculator = rosu_pp::taiko::PpCalculator::new(&map).mods(*mods);
let result = calculator.calculate();
let result = rosu_pp::taiko::PpCalculator::new(&map)
.mods(*mods)
.calculate();
assert!(
(result.stars - stars).abs() < star_margin,