Skip to content

Commit

Permalink
split test using rstest_reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
phenylshima committed Feb 22, 2024
1 parent 5f62c5b commit 91dd119
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ rayon = "1.6.1"
regex = "1.10.0"
reqwest = { version = "0.11.13", default-features = false }
rstest = "0.15.0"
rstest_reuse = "0.6.0"
serde = "1.0.145"
serde_json = "1.0.85"
serde_with = "3.3.0"
Expand Down
1 change: 1 addition & 0 deletions crates/voicevox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ zip.workspace = true
heck.workspace = true
pretty_assertions.workspace = true
rstest.workspace = true
rstest_reuse.workspace = true
test_util.workspace = true
tokio = { workspace = true, features = ["rt", "macros"] }

Expand Down
25 changes: 23 additions & 2 deletions crates/voicevox_core/src/engine/full_context_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ mod chunk_by {

#[cfg(test)]
mod tests {
use rstest_reuse::*;

use ::test_util::OPEN_JTALK_DIC_DIR;
use rstest::rstest;

Expand All @@ -296,6 +298,7 @@ mod tests {
};
use jlabel::Label;

#[template]
#[rstest]
#[case(
"いぇ",
Expand Down Expand Up @@ -699,17 +702,24 @@ mod tests {
),
]
)]
#[tokio::test]
async fn parse_labels(
fn label_cases(
#[case] text: &str,
#[case] labels: &[&str],
#[case] accent_phrase: &[AccentPhraseModel],
) {
}

#[apply(label_cases)]
#[tokio::test]
async fn openjtalk(text: &str, labels: &[&str], _accent_phrase: &[AccentPhraseModel]) {
let openjtalk = crate::tokio::OpenJtalk::new(OPEN_JTALK_DIC_DIR)
.await
.unwrap();
assert_eq!(&openjtalk.extract_fullcontext(text).unwrap(), labels);
}

#[apply(label_cases)]
fn parse_labels(_text: &str, labels: &[&str], accent_phrase: &[AccentPhraseModel]) {
let parsed_labels = labels
.into_iter()
.map(|s| Label::from_str(s).unwrap())
Expand All @@ -719,7 +729,18 @@ mod tests {
&generate_accent_phrases(&parsed_labels).unwrap(),
accent_phrase
);
}

#[apply(label_cases)]
#[tokio::test]
async fn extract_fullcontext(
text: &str,
_labels: &[&str],
accent_phrase: &[AccentPhraseModel],
) {
let openjtalk = crate::tokio::OpenJtalk::new(OPEN_JTALK_DIC_DIR)
.await
.unwrap();
assert_eq!(
&extract_full_context_label(&openjtalk, text).unwrap(),
accent_phrase
Expand Down
2 changes: 2 additions & 0 deletions crates/voicevox_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub mod tokio;

#[cfg(test)]
mod test_util;
#[cfg(test)]
use rstest_reuse;

pub use self::{
devices::SupportedDevices,
Expand Down

0 comments on commit 91dd119

Please sign in to comment.