Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sonar project analysis properties overrides
sonar.projectKey=LizardByte_libdisplaydevice
sonar.cfamily.reportingCppStandardOverride=c++20
3 changes: 2 additions & 1 deletion src/windows/win_api_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "display_device/windows/win_api_utils.h"

// system includes
#include <format>
#include <unordered_set>

// local includes
Expand Down Expand Up @@ -34,7 +35,7 @@ namespace {
* @examples_end
*/
std::string toString(const LUID &id) {
return std::to_string(id.HighPart) + std::to_string(id.LowPart);
return std::format("{}{}", id.HighPart, id.LowPart);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/windows/win_display_device_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// system includes
#include <algorithm>
#include <format>
#include <unordered_set>

// local includes
Expand Down Expand Up @@ -75,7 +76,7 @@ namespace display_device {
return {};
}

const std::string lazy_lookup {std::to_string(source_mode->position.x) + std::to_string(source_mode->position.y)};
const std::string lazy_lookup {std::format("{}{}", source_mode->position.x, source_mode->position.y)};
auto index_it {position_to_topology_index.find(lazy_lookup)};

if (index_it == std::end(position_to_topology_index)) {
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/general/test_logging.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// system includes
#include <exception>
#include <format>

// local includes
#include "display_device/logging.h"
Expand Down Expand Up @@ -130,7 +131,7 @@
std::string output;
logger.setLogLevel(level::verbose);
logger.setCustomCallback([&output](const level level, const std::string &value) {
output = std::to_string(static_cast<level_t>(level)) + " " + value;
output = std::format("{} {}", static_cast<level_t>(level), value);

Check warning on line 134 in tests/unit/general/test_logging.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "std::to_underlying" to cast enums to their underlying type.

See more on https://sonarcloud.io/project/issues?id=LizardByte_libdisplaydevice&issues=AZ6qFONyQw83x_y7bhHY&open=AZ6qFONyQw83x_y7bhHY&pullRequest=252
});

logger.write(level::verbose, "Hello World!");
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/windows/test_win_api_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// system includes
#include <format>

// local includes
#include "display_device/windows/win_api_utils.h"
#include "fixtures/fixtures.h"
Expand All @@ -18,15 +21,15 @@ namespace {
for (int i = 1; i <= number_of_calls; ++i) {
EXPECT_CALL(m_layer, getMonitorDevicePath(_))
.Times(1)
.WillOnce(Return("Path" + std::to_string(i)))
.WillOnce(Return(std::format("Path{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(m_layer, getDisplayName(_))
.Times(1)
.WillOnce(Return("DisplayName" + std::to_string(i)))
.WillOnce(Return(std::format("DisplayName{}", i)))
.RetiresOnSaturation();
}
}
Expand Down
15 changes: 9 additions & 6 deletions tests/unit/windows/test_win_display_device_general.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// system includes
#include <format>

// local includes
#include "display_device/windows/settings_utils.h"
#include "display_device/windows/win_api_layer.h"
Expand Down Expand Up @@ -109,15 +112,15 @@ TEST_F_S_MOCKED(EnumAvailableDevices) {
for (int i = 1; i <= 3; ++i) {
EXPECT_CALL(*m_layer, getMonitorDevicePath(_))
.Times(1)
.WillOnce(Return("Path" + std::to_string(i)))
.WillOnce(Return(std::format("Path{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
.WillOnce(Return("DisplayName" + std::to_string(i)))
.WillOnce(Return(std::format("DisplayName{}", i)))
.RetiresOnSaturation();
}

Expand Down Expand Up @@ -220,15 +223,15 @@ TEST_F_S_MOCKED(EnumAvailableDevices, MissingSourceModes) {
for (int i = 1; i <= 2; ++i) {
EXPECT_CALL(*m_layer, getMonitorDevicePath(_))
.Times(1)
.WillOnce(Return("Path" + std::to_string(i)))
.WillOnce(Return(std::format("Path{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
.WillOnce(Return("DisplayName" + std::to_string(i)))
.WillOnce(Return(std::format("DisplayName{}", i)))
.RetiresOnSaturation();
}

Expand Down
5 changes: 4 additions & 1 deletion tests/unit/windows/test_win_display_device_hdr.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// system includes
#include <format>

// local includes
#include "display_device/windows/settings_utils.h"
#include "display_device/windows/win_api_layer.h"
Expand Down Expand Up @@ -35,7 +38,7 @@ namespace {
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
Expand Down
15 changes: 8 additions & 7 deletions tests/unit/windows/test_win_display_device_modes.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// system includes
#include <format>
#include <ranges>

// local includes
Expand Down Expand Up @@ -39,7 +40,7 @@ namespace {
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
Expand Down Expand Up @@ -69,30 +70,30 @@ namespace {
for (int i = 1; i <= entry; ++i) {
EXPECT_CALL(*m_layer, getMonitorDevicePath(_))
.Times(1)
.WillOnce(Return("Path" + std::to_string(i)))
.WillOnce(Return(std::format("Path{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
.WillOnce(Return("DisplayName" + std::to_string(i)))
.WillOnce(Return(std::format("DisplayName{}", i)))
.RetiresOnSaturation();
}

for (int i = 1; i <= 4; ++i) {
EXPECT_CALL(*m_layer, getMonitorDevicePath(_))
.Times(1)
.WillOnce(Return("Path" + std::to_string(i)))
.WillOnce(Return(std::format("Path{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
.WillOnce(Return("DisplayName" + std::to_string(i)))
.WillOnce(Return(std::format("DisplayName{}", i)))
.RetiresOnSaturation();
}
}
Expand Down
13 changes: 8 additions & 5 deletions tests/unit/windows/test_win_display_device_primary.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// system includes
#include <format>

// local includes
#include "display_device/windows/settings_utils.h"
#include "display_device/windows/win_api_layer.h"
Expand Down Expand Up @@ -36,7 +39,7 @@ namespace {
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
Expand Down Expand Up @@ -202,7 +205,7 @@ TEST_F_S_MOCKED(SetAsPrimary, DuplicatePrimaryDevicesSet) {
for (int i = 1; i <= 4; ++i) {
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
}

Expand Down Expand Up @@ -232,7 +235,7 @@ TEST_F_S_MOCKED(SetAsPrimary, NonDuplicatePrimaryDeviceSet) {
for (int i = 1; i <= 4; ++i) {
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
}

Expand Down Expand Up @@ -262,7 +265,7 @@ TEST_F_S_MOCKED(SetAsPrimary, SharedModeShiftedOnce) {
for (int i = 1; i <= 4; ++i) {
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
}

Expand Down Expand Up @@ -359,7 +362,7 @@ TEST_F_S_MOCKED(SetAsPrimary, FailedToSetDisplayConfig) {
for (int i = 1; i <= 4; ++i) {
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
}

Expand Down
9 changes: 6 additions & 3 deletions tests/unit/windows/test_win_display_device_topology.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// system includes
#include <format>

// local includes
#include "display_device/windows/settings_utils.h"
#include "display_device/windows/win_api_layer.h"
Expand Down Expand Up @@ -37,15 +40,15 @@ namespace {
for (int i = 1; i <= 3; ++i) {
EXPECT_CALL(*m_layer, getMonitorDevicePath(_))
.Times(1)
.WillOnce(Return("Path" + std::to_string(i)))
.WillOnce(Return(std::format("Path{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDeviceId(_))
.Times(1)
.WillOnce(Return("DeviceId" + std::to_string(i)))
.WillOnce(Return(std::format("DeviceId{}", i)))
.RetiresOnSaturation();
EXPECT_CALL(*m_layer, getDisplayName(_))
.Times(1)
.WillOnce(Return("DisplayName" + std::to_string(i)))
.WillOnce(Return(std::format("DisplayName{}", i)))
.RetiresOnSaturation();
}
}
Expand Down
Loading