-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Delta Text not Corresponding Correctly
Fixes #75
- Loading branch information
1 parent
76b8597
commit 17be26d
Showing
2 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use {GeneralLayoutSettings, Run, Segment, Timer}; | ||
use super::Component; | ||
|
||
#[test] | ||
fn comparison_text() { | ||
let mut run = Run::new(); | ||
run.push_segment(Segment::new("Ok")); | ||
|
||
let timer = Timer::new(run).unwrap(); | ||
let mut delta_comp = Component::new(); | ||
let settings = GeneralLayoutSettings::default(); | ||
|
||
// No Override | ||
delta_comp.settings_mut().comparison_override = None; | ||
assert_eq!(delta_comp.name(), "Delta"); // Displayed in Layout Editor | ||
assert_eq!( | ||
delta_comp.state(&timer, &settings).text, | ||
timer.current_comparison() | ||
); // Displayed in Layout | ||
|
||
// Good Override | ||
let mut comp = "Personal Best"; | ||
delta_comp.settings_mut().comparison_override = Some(format!("{}", comp)); | ||
assert_eq!(delta_comp.name(), format!("Delta ({})", comp)); | ||
assert_eq!( | ||
delta_comp.state(&timer, &settings).text, | ||
format!("{}", comp) | ||
); | ||
|
||
// Good Override | ||
comp = "Best Segments"; | ||
delta_comp.settings_mut().comparison_override = Some(format!("{}", comp)); | ||
assert_eq!(delta_comp.name(), format!("Delta ({})", comp)); | ||
assert_eq!( | ||
delta_comp.state(&timer, &settings).text, | ||
format!("{}", comp) | ||
); | ||
|
||
// Good Override | ||
comp = "None"; | ||
delta_comp.settings_mut().comparison_override = Some(format!("{}", comp)); | ||
assert_eq!(delta_comp.name(), format!("Delta ({})", comp)); | ||
assert_eq!( | ||
delta_comp.state(&timer, &settings).text, | ||
format!("{}", comp) | ||
); | ||
|
||
// Bad Override | ||
comp = "Fake Comparison"; | ||
delta_comp.settings_mut().comparison_override = Some(format!("{}", comp)); | ||
assert_eq!(delta_comp.name(), format!("Delta ({})", comp)); | ||
assert_eq!( | ||
delta_comp.state(&timer, &settings).text, | ||
timer.current_comparison() | ||
); | ||
} |