From 98c9db98e38c4300b3967e32652b2a19604c49ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 2 Mar 2023 11:01:08 +0100 Subject: [PATCH] tests/monitor/default-scale: Use a large epsilon To have the test case say e.g. 1.75 while the effective scale is 1.74863386, use an epsilon of 0.2. Fixes: a6217c720e4f ("tests: Add tests for monitor_calculate_mode_scale") Part-of: --- src/tests/monitor-unit-tests.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index 2221d21a8..57579cc4d 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -9324,6 +9324,11 @@ meta_test_monitor_calculate_mode_scale (void) }, }; static const int n_cases = 1; + /* Set a rather high scale epsilon, to have "easy" scales as the + * expectations, while ignoring that the actual scaling factors are slightly + * different, e.g. 1.74863386 instead of 1.75. + */ + const float scale_epsilon = 0.2; MetaMonitorManager *manager; MetaMonitorManagerTest *manager_test; @@ -9367,7 +9372,7 @@ meta_test_monitor_calculate_mode_scale (void) emulate_hotplug (test_setup); logical_monitor = manager->logical_monitors->data; g_assert_cmpfloat_with_epsilon (logical_monitor->scale, cases[i].exp, - FLT_EPSILON); + scale_epsilon); } }