mania & fruits test cases added
This commit is contained in:
+210
@@ -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
@@ -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,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
// TODO
|
||||
|
||||
+3
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user