removed tests & fixed code in documentation
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ use crate::{Beatmap, Mods, PpResult, StarResult};
|
||||
/// let map: Beatmap = ...
|
||||
/// # */
|
||||
/// # let map = Beatmap::default();
|
||||
/// let pp_result: PpResult = FruitsPP::new(&map)
|
||||
/// let pp_result = FruitsPP::new(&map)
|
||||
/// .mods(8 + 64) // HDDT
|
||||
/// .combo(1234)
|
||||
/// .misses(1)
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ use crate::{Beatmap, Mods, PpResult, StarResult};
|
||||
/// let map: Beatmap = ...
|
||||
/// # */
|
||||
/// # let map = Beatmap::default();
|
||||
/// let pp_result: PpResult = ManiaPP::new(&map)
|
||||
/// let pp_result = ManiaPP::new(&map)
|
||||
/// .mods(64) // DT
|
||||
/// .score(765_432)
|
||||
/// .calculate();
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ use crate::{Beatmap, Mods, PpResult, StarResult};
|
||||
/// let map: Beatmap = ...
|
||||
/// # */
|
||||
/// # let map = Beatmap::default();
|
||||
/// let pp_result: PpResult = OsuPP::new(&map)
|
||||
/// let pp_result = OsuPP::new(&map)
|
||||
/// .mods(8 + 64) // HDDT
|
||||
/// .combo(1234)
|
||||
/// .misses(1)
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ use crate::{Beatmap, Mods, PpResult, StarResult};
|
||||
/// let map: Beatmap = ...
|
||||
/// # */
|
||||
/// # let map = Beatmap::default();
|
||||
/// let pp_result: PpResult = TaikoPP::new(&map)
|
||||
/// let pp_result = TaikoPP::new(&map)
|
||||
/// .mods(8 + 64) // HDDT
|
||||
/// .combo(1234)
|
||||
/// .misses(1)
|
||||
|
||||
-261
@@ -1,261 +0,0 @@
|
||||
#![cfg(feature = "fruits")]
|
||||
|
||||
extern crate rosu_pp;
|
||||
|
||||
use rosu_pp::Beatmap;
|
||||
|
||||
struct MapResult {
|
||||
map_id: u32,
|
||||
mods: u32,
|
||||
stars: f32,
|
||||
pp: f32,
|
||||
}
|
||||
|
||||
macro_rules! assert_result {
|
||||
($kind:expr => $result:expr, $margin:expr, $expected:ident, $map_id:ident, $mods:ident) => {
|
||||
assert!(
|
||||
($result - $expected).abs() < $margin * $expected,
|
||||
"\n{kind}:\n\
|
||||
Calculated: {calculated} | Expected: {expected}\n \
|
||||
=> {margin} margin ({allowed} allowed)\n\
|
||||
[map {map} | mods {mods}]\n",
|
||||
kind = $kind,
|
||||
calculated = $result,
|
||||
expected = $expected,
|
||||
margin = ($result - $expected).abs(),
|
||||
allowed = $margin * $expected,
|
||||
map = $map_id,
|
||||
mods = $mods
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
fn fruits_test(map: Beatmap, result: &MapResult) {
|
||||
let star_margin = 0.0001;
|
||||
let pp_margin = 0.0001;
|
||||
|
||||
let MapResult {
|
||||
map_id,
|
||||
mods,
|
||||
stars,
|
||||
pp,
|
||||
} = result;
|
||||
|
||||
let result = rosu_pp::FruitsPP::new(&map).mods(*mods).calculate();
|
||||
|
||||
assert_result!("Stars" => result.stars(), star_margin, stars, map_id, mods);
|
||||
assert_result!("PP" => result.pp(), pp_margin, pp, map_id, mods);
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "async_std", feature = "async_tokio")))]
|
||||
#[test]
|
||||
fn fruits_sync() {
|
||||
for result in RESULTS {
|
||||
let file = match std::fs::File::open(format!("./maps/{}.osu", result.map_id)) {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file) {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
fruits_test(map, result);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_tokio")]
|
||||
#[test]
|
||||
fn fruits_async_tokio() {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.expect("could not start runtime")
|
||||
.block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match tokio::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
fruits_test(map, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_std")]
|
||||
#[test]
|
||||
fn fruits_async_std() {
|
||||
async_std::task::block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match async_std::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
fruits_test(map, result);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const RESULTS: &[MapResult] = &[
|
||||
MapResult {
|
||||
map_id: 1977380,
|
||||
mods: 256,
|
||||
stars: 2.053266215316665,
|
||||
pp: 45.018113339112304,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1977380,
|
||||
mods: 0,
|
||||
stars: 2.5695489769068742,
|
||||
pp: 67.73537806280385,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1977380,
|
||||
mods: 8,
|
||||
stars: 2.5695489769068742,
|
||||
pp: 81.28245367536461,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1977380,
|
||||
mods: 64,
|
||||
stars: 3.5912721232736073,
|
||||
pp: 141.25524875691985,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1977380,
|
||||
mods: 16,
|
||||
stars: 3.1515873669521928,
|
||||
pp: 112.14972254944568,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1977380,
|
||||
mods: 2,
|
||||
stars: 3.0035260129778396,
|
||||
pp: 101.84717128368449,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 1974968,
|
||||
mods: 256,
|
||||
stars: 1.9502416666346483,
|
||||
pp: 42.729265293038324,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1974968,
|
||||
mods: 0,
|
||||
stars: 2.521701539665241,
|
||||
pp: 68.1785376623302,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1974968,
|
||||
mods: 8,
|
||||
stars: 2.521701539665241,
|
||||
pp: 86.927635519471,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1974968,
|
||||
mods: 64,
|
||||
stars: 3.655540489429042,
|
||||
pp: 139.91329907739348,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1974968,
|
||||
mods: 16,
|
||||
stars: 3.566302788963401,
|
||||
pp: 143.81118258776544,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1974968,
|
||||
mods: 2,
|
||||
stars: 2.2029392066882654,
|
||||
pp: 56.44764027057014,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 2420076,
|
||||
mods: 256,
|
||||
stars: 4.789614811665553,
|
||||
pp: 258.3131405278226,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2420076,
|
||||
mods: 0,
|
||||
stars: 6.223136555625056,
|
||||
pp: 471.1417837859138,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2420076,
|
||||
mods: 8,
|
||||
stars: 6.223136555625056,
|
||||
pp: 501.7659929922609,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2420076,
|
||||
mods: 64,
|
||||
stars: 8.910276701845461,
|
||||
pp: 1139.1968785738873,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2420076,
|
||||
mods: 16,
|
||||
stars: 6.54788067620051,
|
||||
pp: 531.2886608194283,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2420076,
|
||||
mods: 2,
|
||||
stars: 6.067971540209479,
|
||||
pp: 446.888877247154,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 2206596,
|
||||
mods: 256,
|
||||
stars: 4.7660034867565795,
|
||||
pp: 300.0108412850544,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2206596,
|
||||
mods: 0,
|
||||
stars: 6.157660207091584,
|
||||
pp: 531.0398776668264,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2206596,
|
||||
mods: 8,
|
||||
stars: 6.157660207091584,
|
||||
pp: 573.5230526869998,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2206596,
|
||||
mods: 64,
|
||||
stars: 8.937404638714733,
|
||||
pp: 1316.2400280229178,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2206596,
|
||||
mods: 16,
|
||||
stars: 6.8639096665110735,
|
||||
pp: 684.8296373011866,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 2206596,
|
||||
mods: 2,
|
||||
stars: 5.60279198088948,
|
||||
pp: 447.8862884246722,
|
||||
},
|
||||
];
|
||||
-170
@@ -1,170 +0,0 @@
|
||||
#![cfg(feature = "mania")]
|
||||
|
||||
extern crate rosu_pp;
|
||||
|
||||
use rosu_pp::Beatmap;
|
||||
|
||||
struct MapResult {
|
||||
map_id: u32,
|
||||
mods: u32,
|
||||
stars: f32,
|
||||
pp: f32,
|
||||
}
|
||||
|
||||
macro_rules! assert_result {
|
||||
($kind:expr => $result:expr, $margin:expr, $expected:ident, $map_id:ident, $mods:ident) => {
|
||||
assert!(
|
||||
($result - $expected).abs() < $margin * $expected,
|
||||
"\n{kind}:\n\
|
||||
Calculated: {calculated} | Expected: {expected}\n \
|
||||
=> {margin} margin ({allowed} allowed)\n\
|
||||
[map {map} | mods {mods}]\n",
|
||||
kind = $kind,
|
||||
calculated = $result,
|
||||
expected = $expected,
|
||||
margin = ($result - $expected).abs(),
|
||||
allowed = $margin * $expected,
|
||||
map = $map_id,
|
||||
mods = $mods
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
fn mania_test(map: Beatmap, result: &MapResult) {
|
||||
let star_margin = 0.00001;
|
||||
let pp_margin = 0.00001;
|
||||
|
||||
let MapResult {
|
||||
map_id,
|
||||
mods,
|
||||
stars,
|
||||
pp,
|
||||
} = result;
|
||||
|
||||
let result = rosu_pp::ManiaPP::new(&map).mods(*mods).calculate();
|
||||
|
||||
assert_result!("Stars" => result.stars(), star_margin, stars, map_id, mods);
|
||||
assert_result!("PP" => result.pp(), pp_margin, pp, map_id, mods);
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "async_std", feature = "async_tokio")))]
|
||||
#[test]
|
||||
fn mania_sync() {
|
||||
for result in RESULTS {
|
||||
let file = match std::fs::File::open(format!("./maps/{}.osu", result.map_id)) {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file) {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
mania_test(map, result);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_tokio")]
|
||||
#[test]
|
||||
fn mania_async_tokio() {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.expect("could not start runtime")
|
||||
.block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match tokio::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
mania_test(map, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_std")]
|
||||
#[test]
|
||||
fn mania_async_std() {
|
||||
async_std::task::block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match async_std::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
mania_test(map, result);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const RESULTS: &[MapResult] = &[
|
||||
MapResult {
|
||||
map_id: 1355822,
|
||||
mods: 256,
|
||||
stars: 2.2684169993943653,
|
||||
pp: 43.53325918930298,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1355822,
|
||||
mods: 0,
|
||||
stars: 2.7966565927524574,
|
||||
pp: 71.54271564752817,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1355822,
|
||||
mods: 64,
|
||||
stars: 3.7490047677821776,
|
||||
pp: 140.30066841634704,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 1974394,
|
||||
mods: 256,
|
||||
stars: 3.873141963622833,
|
||||
pp: 155.74720954392703,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1974394,
|
||||
mods: 0,
|
||||
stars: 4.801793001581714,
|
||||
pp: 254.50572065264748,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1974394,
|
||||
mods: 64,
|
||||
stars: 6.518026726802542,
|
||||
pp: 508.5082744648102,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 992512,
|
||||
mods: 256,
|
||||
stars: 5.282601951185166,
|
||||
pp: 316.1318109880581,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 992512,
|
||||
mods: 0,
|
||||
stars: 6.536292432114728,
|
||||
pp: 511.72773348069154,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 992512,
|
||||
mods: 64,
|
||||
stars: 8.974411542576131,
|
||||
pp: 1043.3119173151915,
|
||||
},
|
||||
];
|
||||
-238
@@ -1,238 +0,0 @@
|
||||
#![cfg(feature = "osu")]
|
||||
|
||||
extern crate rosu_pp;
|
||||
|
||||
use rosu_pp::Beatmap;
|
||||
|
||||
struct MapResult {
|
||||
map_id: u32,
|
||||
mods: u32,
|
||||
stars: f32,
|
||||
pp: f32,
|
||||
}
|
||||
|
||||
macro_rules! assert_result {
|
||||
($kind:expr => $result:expr, $margin:expr, $expected:ident, $map_id:ident, $mods:ident) => {
|
||||
assert!(
|
||||
($result - $expected).abs() < $margin * $expected,
|
||||
"\n{kind}:\n\
|
||||
Calculated: {calculated} | Expected: {expected}\n \
|
||||
=> {margin} margin ({allowed} allowed)\n\
|
||||
[map {map} | mods {mods}]\n",
|
||||
kind = $kind,
|
||||
calculated = $result,
|
||||
expected = $expected,
|
||||
margin = ($result - $expected).abs(),
|
||||
allowed = $margin * $expected,
|
||||
map = $map_id,
|
||||
mods = $mods
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
fn margin() -> f32 {
|
||||
if cfg!(feature = "no_sliders_no_leniency") {
|
||||
0.0075
|
||||
} else if cfg!(feature = "no_leniency") {
|
||||
0.0025
|
||||
} else if cfg!(feature = "all_included") {
|
||||
0.001
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
fn osu_test(map: Beatmap, result: &MapResult) {
|
||||
let margin = margin();
|
||||
|
||||
let star_margin = margin;
|
||||
let pp_margin = margin;
|
||||
|
||||
let MapResult {
|
||||
map_id,
|
||||
mods,
|
||||
stars,
|
||||
pp,
|
||||
} = result;
|
||||
|
||||
let result = rosu_pp::OsuPP::new(&map).mods(*mods).calculate();
|
||||
|
||||
assert_result!("Stars" => result.stars(), star_margin, stars, map_id, mods);
|
||||
assert_result!("PP" => result.pp(), pp_margin, pp, map_id, mods);
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "async_std", feature = "async_tokio")))]
|
||||
#[test]
|
||||
fn osu_sync() {
|
||||
for result in RESULTS {
|
||||
let file = match std::fs::File::open(format!("./maps/{}.osu", result.map_id)) {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file) {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
osu_test(map, result);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_tokio")]
|
||||
#[test]
|
||||
fn osu_async_tokio() {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.expect("could not start runtime")
|
||||
.block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match tokio::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
osu_test(map, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_std")]
|
||||
#[test]
|
||||
fn osu_async_std() {
|
||||
async_std::task::block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match async_std::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
osu_test(map, result);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const RESULTS: &[MapResult] = &[
|
||||
MapResult {
|
||||
map_id: 1851299,
|
||||
mods: 256,
|
||||
stars: 4.19951953364192,
|
||||
pp: 95.35544846090738,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1851299,
|
||||
mods: 0,
|
||||
stars: 5.305946555352317,
|
||||
pp: 188.7611225698759,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1851299,
|
||||
mods: 8,
|
||||
stars: 5.305946555352317,
|
||||
pp: 207.87782991080368,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1851299,
|
||||
mods: 64,
|
||||
stars: 7.352573837272898,
|
||||
pp: 465.60165096277717,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1851299,
|
||||
mods: 16,
|
||||
stars: 5.628029058321052,
|
||||
pp: 239.33966091681467,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1851299,
|
||||
mods: 2,
|
||||
stars: 4.892665488817249,
|
||||
pp: 108.66545494037493,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 70090,
|
||||
mods: 256,
|
||||
stars: 2.2531214736733975,
|
||||
pp: 17.064864347414005,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 70090,
|
||||
mods: 0,
|
||||
stars: 2.7853401027561353,
|
||||
pp: 39.80360462535964,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 70090,
|
||||
mods: 8,
|
||||
stars: 2.7853401027561353,
|
||||
pp: 45.27724541951056,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 70090,
|
||||
mods: 64,
|
||||
stars: 3.7775299223395877,
|
||||
pp: 108.27132697867293,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 70090,
|
||||
mods: 16,
|
||||
stars: 3.0128373294988626,
|
||||
pp: 83.70428900396428,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 70090,
|
||||
mods: 2,
|
||||
stars: 2.673167484837261,
|
||||
pp: 21.254867316318986,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 1241370,
|
||||
mods: 256,
|
||||
stars: 5.558026586611704,
|
||||
pp: 334.51647189180727,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1241370,
|
||||
mods: 0,
|
||||
stars: 6.983848076867755,
|
||||
pp: 649.1653315906666,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1241370,
|
||||
mods: 8,
|
||||
stars: 6.983848076867755,
|
||||
pp: 710.594432790455,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1241370,
|
||||
mods: 64,
|
||||
stars: 11.076248857241552,
|
||||
pp: 2378.593642686663,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1241370,
|
||||
mods: 16,
|
||||
stars: 7.616427878599069,
|
||||
pp: 843.421001465897,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1241370,
|
||||
mods: 2,
|
||||
stars: 6.289772601786212,
|
||||
pp: 354.960619132034,
|
||||
},
|
||||
];
|
||||
-189
@@ -1,189 +0,0 @@
|
||||
#![cfg(feature = "taiko")]
|
||||
|
||||
extern crate rosu_pp;
|
||||
|
||||
use rosu_pp::Beatmap;
|
||||
|
||||
struct MapResult {
|
||||
map_id: u32,
|
||||
mods: u32,
|
||||
stars: f32,
|
||||
pp: f32,
|
||||
}
|
||||
|
||||
macro_rules! assert_result {
|
||||
($kind:expr => $result:expr, $margin:expr, $expected:ident, $map_id:ident, $mods:ident) => {
|
||||
assert!(
|
||||
($result - $expected).abs() < $margin * $expected,
|
||||
"\n{kind}:\n\
|
||||
Calculated: {calculated} | Expected: {expected}\n \
|
||||
=> {margin} margin ({allowed} allowed)\n\
|
||||
[map {map} | mods {mods}]\n",
|
||||
kind = $kind,
|
||||
calculated = $result,
|
||||
expected = $expected,
|
||||
margin = ($result - $expected).abs(),
|
||||
allowed = $margin * $expected,
|
||||
map = $map_id,
|
||||
mods = $mods
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
fn taiko_test(map: Beatmap, result: &MapResult) {
|
||||
let star_margin = 0.0001;
|
||||
let pp_margin = 0.0001;
|
||||
|
||||
let MapResult {
|
||||
map_id,
|
||||
mods,
|
||||
stars,
|
||||
pp,
|
||||
} = result;
|
||||
|
||||
let result = rosu_pp::TaikoPP::new(&map).mods(*mods).calculate();
|
||||
|
||||
assert_result!("Stars" => result.stars(), star_margin, stars, map_id, mods);
|
||||
assert_result!("PP" => result.pp(), pp_margin, pp, map_id, mods);
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "async_std", feature = "async_tokio")))]
|
||||
#[test]
|
||||
fn taiko_sync() {
|
||||
for result in RESULTS {
|
||||
let file = match std::fs::File::open(format!("./maps/{}.osu", result.map_id)) {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file) {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
taiko_test(map, result);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_tokio")]
|
||||
#[test]
|
||||
fn taiko_async_tokio() {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.expect("could not start runtime")
|
||||
.block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match tokio::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
taiko_test(map, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(feature = "async_std")]
|
||||
#[test]
|
||||
fn taiko_async_std() {
|
||||
async_std::task::block_on(async {
|
||||
for result in RESULTS {
|
||||
let file =
|
||||
match async_std::fs::File::open(format!("./maps/{}.osu", result.map_id)).await {
|
||||
Ok(file) => file,
|
||||
Err(why) => panic!("Could not open file {}.osu: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
let map = match Beatmap::parse(file).await {
|
||||
Ok(map) => map,
|
||||
Err(why) => panic!("Error while parsing map {}: {}", result.map_id, why),
|
||||
};
|
||||
|
||||
taiko_test(map, result);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const RESULTS: &[MapResult] = &[
|
||||
MapResult {
|
||||
map_id: 110219,
|
||||
mods: 256,
|
||||
stars: 4.08968885024159,
|
||||
pp: 172.2618767481684,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 110219,
|
||||
mods: 0,
|
||||
stars: 5.137432251440863,
|
||||
pp: 253.6918375585501,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 110219,
|
||||
mods: 64,
|
||||
stars: 6.7868926972961,
|
||||
pp: 420.7721479461209,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 168450,
|
||||
mods: 256,
|
||||
stars: 3.906304814419791,
|
||||
pp: 159.50978823553345,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 168450,
|
||||
mods: 0,
|
||||
stars: 4.740171803038067,
|
||||
pp: 226.46677950133315,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 168450,
|
||||
mods: 64,
|
||||
stars: 5.900723352868479,
|
||||
pp: 352.4632039368069,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 1097541,
|
||||
mods: 256,
|
||||
stars: 4.001086710846427,
|
||||
pp: 181.1195995270953,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1097541,
|
||||
mods: 0,
|
||||
stars: 4.891409786886079,
|
||||
pp: 258.3724413997574,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1097541,
|
||||
mods: 64,
|
||||
stars: 6.588219669147997,
|
||||
pp: 434.0217833573784,
|
||||
},
|
||||
// -----
|
||||
MapResult {
|
||||
map_id: 1432878,
|
||||
mods: 256,
|
||||
stars: 3.5826958150176584,
|
||||
pp: 127.191831998499,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1432878,
|
||||
mods: 0,
|
||||
stars: 4.416206873466799,
|
||||
pp: 183.53015221780785,
|
||||
},
|
||||
MapResult {
|
||||
map_id: 1432878,
|
||||
mods: 64,
|
||||
stars: 5.912036178782906,
|
||||
pp: 308.1608793395345,
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user