srctree

Robin Linden parent 41b13b25 2ea8e2da
os/test: Update to the less magical etest variant

inlinesplit
os/linux_test.cpp added: 19, removed: 20, total 0
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2022-2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -11,41 +11,41 @@
 
#include "os/os.h"
 
#include "etest/etest.h"
#include "etest/etest2.h"
 
// This is the header POSIX says we need to include.
// NOLINTNEXTLINE(modernize-deprecated-headers)
#include <stdlib.h>
 
using etest::expect_eq;
 
// NOLINTBEGIN(concurrency-mt-unsafe): No threads here.
 
int main() {
etest::Suite s{"os/linux"};
 
// Ensure that the system's environment doesn't affect the test result.
unsetenv("HST_SCALE");
unsetenv("QT_SCALE_FACTOR");
unsetenv("GDK_SCALE");
unsetenv("ELM_SCALE");
 
etest::test("active_window_scale_factor", [] {
s.add_test("active_window_scale_factor", [](etest::IActions &a) {
// We default to 1 when no GUI toolkit has an opinion.
expect_eq(os::active_window_scale_factor(), 1u);
a.expect_eq(os::active_window_scale_factor(), 1u);
 
setenv("ELM_SCALE", "2", false);
expect_eq(os::active_window_scale_factor(), 2u);
a.expect_eq(os::active_window_scale_factor(), 2u);
 
setenv("GDK_SCALE", "5", false);
expect_eq(os::active_window_scale_factor(), 5u);
a.expect_eq(os::active_window_scale_factor(), 5u);
 
setenv("QT_SCALE_FACTOR", "10", false);
expect_eq(os::active_window_scale_factor(), 10u);
a.expect_eq(os::active_window_scale_factor(), 10u);
 
setenv("HST_SCALE", "50", false);
expect_eq(os::active_window_scale_factor(), 50u);
a.expect_eq(os::active_window_scale_factor(), 50u);
});
 
return etest::run_all_tests();
return s.run();
}
 
// NOLINTEND(concurrency-mt-unsafe)
 
os/os_test.cpp added: 19, removed: 20, total 0
@@ -1,18 +1,17 @@
// SPDX-FileCopyrightText: 2021 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "os/os.h"
 
#include "etest/etest.h"
 
using etest::expect;
#include "etest/etest2.h"
 
int main() {
etest::test("font_paths", [] {
etest::Suite s{"os"};
s.add_test("font_paths", [](etest::IActions &a) {
auto font_paths = os::font_paths();
expect(!font_paths.empty());
a.expect(!font_paths.empty());
});
 
return etest::run_all_tests();
return s.run();
}