added tests, use specific CI
This commit is contained in:
@@ -72,3 +72,53 @@ pub fn calc_progress(position: f64, duration: f64) -> f64 {
|
||||
pub fn convert_percent_to_volume(percent: f64) -> f64 {
|
||||
percent_to_volume(percent)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_format_time_seconds() {
|
||||
assert_eq!(format_time_seconds(0.0), "0:00");
|
||||
assert_eq!(format_time_seconds(59.0), "0:59");
|
||||
assert_eq!(format_time_seconds(60.0), "1:00");
|
||||
assert_eq!(format_time_seconds(125.0), "2:05");
|
||||
assert_eq!(format_time_seconds(3661.0), "61:01");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_time_seconds_long() {
|
||||
assert_eq!(format_time_seconds_long(0.0), "0:00");
|
||||
assert_eq!(format_time_seconds_long(59.0), "0:59");
|
||||
assert_eq!(format_time_seconds_long(3599.0), "59:59");
|
||||
assert_eq!(format_time_seconds_long(3600.0), "1:00:00");
|
||||
assert_eq!(format_time_seconds_long(3661.0), "1:01:01");
|
||||
assert_eq!(format_time_seconds_long(7384.0), "2:03:04");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_convert_ticks_to_seconds() {
|
||||
assert_eq!(convert_ticks_to_seconds(0), 0.0);
|
||||
assert_eq!(convert_ticks_to_seconds(10_000_000), 1.0);
|
||||
assert_eq!(convert_ticks_to_seconds(5_000_000), 0.5);
|
||||
assert_eq!(convert_ticks_to_seconds(60_000_000), 6.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calc_progress() {
|
||||
assert_eq!(calc_progress(0.0, 100.0), 0.0);
|
||||
assert_eq!(calc_progress(50.0, 100.0), 50.0);
|
||||
assert_eq!(calc_progress(100.0, 100.0), 100.0);
|
||||
assert_eq!(calc_progress(25.0, 0.0), 0.0); // Invalid duration
|
||||
assert_eq!(calc_progress(150.0, 100.0), 100.0); // Clamped
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_convert_percent_to_volume() {
|
||||
assert_eq!(convert_percent_to_volume(0.0), 0.0);
|
||||
assert_eq!(convert_percent_to_volume(50.0), 0.5);
|
||||
assert_eq!(convert_percent_to_volume(100.0), 1.0);
|
||||
assert_eq!(convert_percent_to_volume(150.0), 1.0); // Clamped
|
||||
assert_eq!(convert_percent_to_volume(-10.0), 0.0); // Clamped
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user