aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dbus/mutter_display_config.rs12
-rw-r--r--src/utils/scale.rs46
2 files changed, 29 insertions, 29 deletions
diff --git a/src/dbus/mutter_display_config.rs b/src/dbus/mutter_display_config.rs
index 6de56b70..b6df149c 100644
--- a/src/dbus/mutter_display_config.rs
+++ b/src/dbus/mutter_display_config.rs
@@ -212,16 +212,16 @@ fn format_diagonal(diagonal_inches: f64) -> String {
#[cfg(test)]
mod tests {
- use k9::snapshot;
+ use insta::assert_snapshot;
use super::*;
#[test]
fn test_format_diagonal() {
- snapshot!(format_diagonal(12.11), "12.1″");
- snapshot!(format_diagonal(13.28), "13.3″");
- snapshot!(format_diagonal(15.6), "15.6″");
- snapshot!(format_diagonal(23.2), "23″");
- snapshot!(format_diagonal(24.8), "25″");
+ assert_snapshot!(format_diagonal(12.11), @"12.1″");
+ assert_snapshot!(format_diagonal(13.28), @"13.3″");
+ assert_snapshot!(format_diagonal(15.6), @"15.6″");
+ assert_snapshot!(format_diagonal(23.2), @"23″");
+ assert_snapshot!(format_diagonal(24.8), @"25″");
}
}
diff --git a/src/utils/scale.rs b/src/utils/scale.rs
index 13337704..ff89b4cb 100644
--- a/src/utils/scale.rs
+++ b/src/utils/scale.rs
@@ -59,7 +59,7 @@ pub fn closest_representable_scale(scale: f64) -> f64 {
#[cfg(test)]
mod tests {
- use k9::snapshot;
+ use insta::assert_snapshot;
use super::*;
@@ -70,37 +70,37 @@ mod tests {
#[test]
fn test_guess_monitor_scale() {
// Librem 5; not enough logical area when scaled
- snapshot!(check((65, 129), (720, 1440)), "1.5");
+ assert_snapshot!(check((65, 129), (720, 1440)), @"1.5");
// OnePlus 6
- snapshot!(check((68, 144), (1080, 2280)), "2.5");
+ assert_snapshot!(check((68, 144), (1080, 2280)), @"2.5");
// Google Pixel 6a
- snapshot!(check((64, 142), (1080, 2400)), "2.5");
+ assert_snapshot!(check((64, 142), (1080, 2400)), @"2.5");
// 13" MacBook Retina
- snapshot!(check((286, 179), (2560, 1600)), "1.75");
+ assert_snapshot!(check((286, 179), (2560, 1600)), @"1.75");
// Surface Laptop Studio
- snapshot!(check((303, 202), (2400, 1600)), "1.5");
+ assert_snapshot!(check((303, 202), (2400, 1600)), @"1.5");
// Dell XPS 9320
- snapshot!(check((290, 180), (3840, 2400)), "2.5");
+ assert_snapshot!(check((290, 180), (3840, 2400)), @"2.5");
// Lenovo ThinkPad X1 Yoga Gen 6
- snapshot!(check((300, 190), (3840, 2400)), "2.5");
+ assert_snapshot!(check((300, 190), (3840, 2400)), @"2.5");
// Generic 23" 1080p
- snapshot!(check((509, 286), (1920, 1080)), "1.0");
+ assert_snapshot!(check((509, 286), (1920, 1080)), @"1");
// Generic 23" 4K
- snapshot!(check((509, 286), (3840, 2160)), "1.75");
+ assert_snapshot!(check((509, 286), (3840, 2160)), @"1.75");
// Generic 27" 4K
- snapshot!(check((598, 336), (3840, 2160)), "1.5");
+ assert_snapshot!(check((598, 336), (3840, 2160)), @"1.5");
// Generic 32" 4K
- snapshot!(check((708, 398), (3840, 2160)), "1.25");
+ assert_snapshot!(check((708, 398), (3840, 2160)), @"1.25");
// Generic 25" 4K; ideal scale is 1.60, should round to 1.5 and 1.0
- snapshot!(check((554, 312), (3840, 2160)), "1.5");
+ assert_snapshot!(check((554, 312), (3840, 2160)), @"1.5");
// Generic 23.5" 4K; ideal scale is 1.70, should round to 1.75 and 2.0
- snapshot!(check((522, 294), (3840, 2160)), "1.75");
+ assert_snapshot!(check((522, 294), (3840, 2160)), @"1.75");
// Lenovo Legion 7 Gen 7 AMD 16"
- snapshot!(check((340, 210), (2560, 1600)), "1.5");
+ assert_snapshot!(check((340, 210), (2560, 1600)), @"1.5");
// Acer Nitro XV320QU LV 31.5"
- snapshot!(check((700, 390), (2560, 1440)), "1.0");
+ assert_snapshot!(check((700, 390), (2560, 1440)), @"1");
// Surface Pro 6
- snapshot!(check((260, 170), (2736, 1824)), "2.0");
+ assert_snapshot!(check((260, 170), (2736, 1824)), @"2");
}
#[test]
@@ -110,11 +110,11 @@ mod tests {
#[test]
fn test_round_scale() {
- snapshot!(closest_representable_scale(1.3), "1.3");
- snapshot!(closest_representable_scale(1.31), "1.3083333333333333");
- snapshot!(closest_representable_scale(1.32), "1.3166666666666667");
- snapshot!(closest_representable_scale(1.33), "1.3333333333333333");
- snapshot!(closest_representable_scale(1.34), "1.3416666666666666");
- snapshot!(closest_representable_scale(1.35), "1.35");
+ assert_snapshot!(closest_representable_scale(1.3), @"1.3");
+ assert_snapshot!(closest_representable_scale(1.31), @"1.3083333333333333");
+ assert_snapshot!(closest_representable_scale(1.32), @"1.3166666666666667");
+ assert_snapshot!(closest_representable_scale(1.33), @"1.3333333333333333");
+ assert_snapshot!(closest_representable_scale(1.34), @"1.3416666666666666");
+ assert_snapshot!(closest_representable_scale(1.35), @"1.35");
}
}