-
Notifications
You must be signed in to change notification settings - Fork 123
[Rust]is_model_loadedを実装した #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rust]is_model_loadedを実装した #151
Conversation
crates/voicevox_core/src/internal.rs
Outdated
pub fn is_model_loaded(speaker_id: i64) -> bool { | ||
unimplemented!() | ||
if let Some(status) = STATUS.lock().unwrap().as_ref() { | ||
status.is_model_loaded(speaker_id as usize) | ||
} else { | ||
false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この関数について、グローバル変数の状態によってテスト結果が変わってしまうためテストが書きにくい状態になっています
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
オブジェクト指向的にはis_model_loadedもSTATUSも同じクラスに含めてしまってシングルトンクラスとしちゃえばテストも書けそうなのですが、Rustだとどうするのが良いんだろう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ちょっと意図が読めないのですが、
シングルトンもグローバル変数もstatic領域に配置してることには変わりないので他のテストの影響を受けてしまうのは変わらないと思います
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static変数を使う部分をテストすることはできないと諦めて、static変数を使う部分と処理をするコードに分けて、後者だけテストするのを意図しています。
その方法の1つがクラス化&シングルトンかなと思った次第です。
#150 (comment) と似ています。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
やるにしてもまとめてやったほうがよさそうですね
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
間違えました・・・
d3f4e84
to
845a491
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* is_model_loadedを実装した * is_model_loadedに渡す数値をspeaker_idではなくmodel_indexにした
内容
id_model_loaded関数を実装しました
関連 Issue
refs #128
その他