Fix/keep two decimals for stability (#2873)

* Fix/keep two decimals

* update test
This commit is contained in:
Jarrett Ye 2023-12-06 08:08:52 +08:00 committed by GitHub
parent 27b2bce604
commit 96ae3dce48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -79,7 +79,7 @@ impl CardData {
pub(crate) fn convert_to_json(&mut self) -> Result<String> {
if let Some(v) = &mut self.fsrs_stability {
round_to_places(v, 1)
round_to_places(v, 2)
}
if let Some(v) = &mut self.fsrs_difficulty {
round_to_places(v, 3)
@ -163,7 +163,7 @@ mod test {
};
assert_eq!(
data.convert_to_json().unwrap(),
r#"{"s":123.5,"d":1.235,"dr":0.99}"#
r#"{"s":123.46,"d":1.235,"dr":0.99}"#
);
}
}