fixed async tests
This commit is contained in:
@@ -87,10 +87,13 @@
|
|||||||
//! taiko::TaikoScoreState,
|
//! taiko::TaikoScoreState,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
|
//! # /*
|
||||||
//! let map = match Beatmap::from_path("/path/to/file.osu") {
|
//! let map = match Beatmap::from_path("/path/to/file.osu") {
|
||||||
//! Ok(map) => map,
|
//! Ok(map) => map,
|
||||||
//! Err(why) => panic!("Error while parsing map: {}", why),
|
//! Err(why) => panic!("Error while parsing map: {}", why),
|
||||||
//! };
|
//! };
|
||||||
|
//! # */
|
||||||
|
//! # let map = Beatmap::default();
|
||||||
//!
|
//!
|
||||||
//! let mods = 8 + 64; // HDDT
|
//! let mods = 8 + 64; // HDDT
|
||||||
//!
|
//!
|
||||||
|
|||||||
+1
-1
@@ -641,7 +641,7 @@ impl ManiaAttributeProvider for PerformanceAttributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(feature = "async_tokio", feature = "async_str")))]
|
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
+1
-1
@@ -739,7 +739,7 @@ impl OsuAttributeProvider for PerformanceAttributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(feature = "async_tokio", feature = "async_str")))]
|
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
+1
-1
@@ -464,7 +464,7 @@ impl TaikoAttributeProvider for PerformanceAttributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(feature = "async_tokio", feature = "async_str")))]
|
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
+5
-5
@@ -8,22 +8,22 @@ pub use self::mode::{Catch, Mania, Mode, Osu, Taiko};
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
macro_rules! test_map {
|
macro_rules! test_map {
|
||||||
($mode:ident) => {{
|
($mode:ident) => {{
|
||||||
#[cfg(not(any(feature = "async_tokio", feature = "async_str")))]
|
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
|
||||||
{ common::test_map::<$mode>() }
|
{ common::test_map::<$mode>() }
|
||||||
#[cfg(any(feature = "async_tokio", feature = "async_str"))]
|
#[cfg(any(feature = "async_tokio", feature = "async_std"))]
|
||||||
{ common::test_map::<$mode>().await }
|
{ common::test_map::<$mode>().await }
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(feature = "async_tokio", feature = "async_str")))]
|
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
|
||||||
pub fn test_map<M: Mode>() -> Beatmap {
|
pub fn test_map<M: Mode>() -> Beatmap {
|
||||||
let path = format!("./maps/{}.osu", M::TEST_MAP_ID);
|
let path = format!("./maps/{}.osu", M::TEST_MAP_ID);
|
||||||
|
|
||||||
Beatmap::from_path(path).unwrap()
|
Beatmap::from_path(path).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "async_tokio", feature = "async_str"))]
|
#[cfg(any(feature = "async_tokio", feature = "async_std"))]
|
||||||
pub async fn test_map() -> Beatmap {
|
pub async fn test_map<M: Mode>() -> Beatmap {
|
||||||
let path = format!("./maps/{}.osu", M::TEST_MAP_ID);
|
let path = format!("./maps/{}.osu", M::TEST_MAP_ID);
|
||||||
|
|
||||||
Beatmap::from_path(path).await.unwrap()
|
Beatmap::from_path(path).await.unwrap()
|
||||||
|
|||||||
+93
-18
@@ -1,15 +1,99 @@
|
|||||||
#![cfg(not(any(feature = "async_tokio", feature = "async_std")))]
|
use rosu_pp::{Beatmap, GameMode};
|
||||||
|
|
||||||
use rosu_pp::GameMode;
|
|
||||||
|
|
||||||
use crate::common::{Catch, Mania, Osu, Taiko};
|
use crate::common::{Catch, Mania, Osu, Taiko};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
#[test]
|
#[cfg(not(any(feature = "async_tokio", feature = "async_std")))]
|
||||||
fn parse_osu() {
|
mod sync {
|
||||||
let map = test_map!(Osu);
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_osu() {
|
||||||
|
assert_osu(test_map!(Osu));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_taiko() {
|
||||||
|
assert_taiko(test_map!(Taiko));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_catch() {
|
||||||
|
assert_catch(test_map!(Catch));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_mania() {
|
||||||
|
assert_mania(test_map!(Mania));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "async_tokio")]
|
||||||
|
mod async_tokio {
|
||||||
|
use tokio::runtime::Builder as RuntimeBuilder;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_osu() {
|
||||||
|
RuntimeBuilder::new_current_thread()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async { assert_osu(test_map!(Osu)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_taiko() {
|
||||||
|
RuntimeBuilder::new_current_thread()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async { assert_taiko(test_map!(Taiko)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_catch() {
|
||||||
|
RuntimeBuilder::new_current_thread()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async { assert_catch(test_map!(Catch)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_mania() {
|
||||||
|
RuntimeBuilder::new_current_thread()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async { assert_mania(test_map!(Mania)) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "async_std")]
|
||||||
|
mod async_tokio {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_osu() {
|
||||||
|
async_std::task::block_on(async { assert_osu(test_map!(Osu)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_taiko() {
|
||||||
|
async_std::task::block_on(async { assert_taiko(test_map!(Taiko)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_catch() {
|
||||||
|
async_std::task::block_on(async { assert_catch(test_map!(Catch)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_mania() {
|
||||||
|
async_std::task::block_on(async { assert_mania(test_map!(Mania)) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn assert_osu(map: Beatmap) {
|
||||||
assert_eq!(map.mode, GameMode::Osu);
|
assert_eq!(map.mode, GameMode::Osu);
|
||||||
assert_eq!(map.version, 14);
|
assert_eq!(map.version, 14);
|
||||||
assert_eq!(map.n_circles, 307);
|
assert_eq!(map.n_circles, 307);
|
||||||
@@ -30,10 +114,7 @@ fn parse_osu() {
|
|||||||
assert_eq!(map.breaks.len(), 1)
|
assert_eq!(map.breaks.len(), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn assert_taiko(map: Beatmap) {
|
||||||
fn parse_taiko() {
|
|
||||||
let map = test_map!(Taiko);
|
|
||||||
|
|
||||||
assert_eq!(map.mode, GameMode::Taiko);
|
assert_eq!(map.mode, GameMode::Taiko);
|
||||||
assert_eq!(map.version, 14);
|
assert_eq!(map.version, 14);
|
||||||
assert_eq!(map.n_circles, 289);
|
assert_eq!(map.n_circles, 289);
|
||||||
@@ -54,10 +135,7 @@ fn parse_taiko() {
|
|||||||
assert_eq!(map.breaks.len(), 0)
|
assert_eq!(map.breaks.len(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn assert_catch(map: Beatmap) {
|
||||||
fn parse_catch() {
|
|
||||||
let map = test_map!(Catch);
|
|
||||||
|
|
||||||
assert_eq!(map.mode, GameMode::Catch);
|
assert_eq!(map.mode, GameMode::Catch);
|
||||||
assert_eq!(map.version, 14);
|
assert_eq!(map.version, 14);
|
||||||
assert_eq!(map.n_circles, 249);
|
assert_eq!(map.n_circles, 249);
|
||||||
@@ -78,10 +156,7 @@ fn parse_catch() {
|
|||||||
assert_eq!(map.breaks.len(), 0)
|
assert_eq!(map.breaks.len(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn assert_mania(map: Beatmap) {
|
||||||
fn parse_mania() {
|
|
||||||
let map = test_map!(Mania);
|
|
||||||
|
|
||||||
assert_eq!(map.mode, GameMode::Mania);
|
assert_eq!(map.mode, GameMode::Mania);
|
||||||
assert_eq!(map.version, 14);
|
assert_eq!(map.version, 14);
|
||||||
assert_eq!(map.n_circles, 2815);
|
assert_eq!(map.n_circles, 2815);
|
||||||
|
|||||||
Reference in New Issue
Block a user