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
20 changes: 15 additions & 5 deletions src/round_robin.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ namespace round_robin_util {
/**
* @brief Iterator that cycles indefinitely over a fixed begin/end range.
*/
template<class V, class It>
template<class V, std::random_access_iterator It>
class round_robin_t: public it_wrap_t<V, round_robin_t<V, It>> {
public:
/**
Expand Down Expand Up @@ -329,11 +329,21 @@ namespace round_robin_util {
/**
* @brief Compare two iterators for equality.
*
* @param other Iterator or container to compare against.
* @return True when both iterators point to equivalent values.
* @param other Iterator to compare against.
* @return True when both iterators refer to the same position.
*/
bool eq(const round_robin_t &other) const {
return *_pos == *other._pos;
return _pos == other._pos;
}

/**
* @brief Compare two iterators by their positions in the wrapped range.
*
* @param other Iterator to compare against.
* @return True when this iterator follows `other` in the wrapped range.
*/
bool gt(const round_robin_t &other) const {
return _pos > other._pos;
}

/**
Expand All @@ -359,7 +369,7 @@ namespace round_robin_util {
* @param end Iterator or pointer marking the end of the input range.
* @return Iterator initialized to `begin` and wrapping before `end`.
*/
template<class V, class It>
template<class V, std::random_access_iterator It>
round_robin_t<V, It> make_round_robin(It begin, It end) {
return round_robin_t<V, It>(begin, end);
}
Expand Down
4 changes: 3 additions & 1 deletion src/stat_trackers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#pragma once

// standard includes
#include <algorithm>
#include <chrono>
#include <cstdint>
#include <functional>
#include <limits>

Expand Down Expand Up @@ -70,7 +72,7 @@ namespace stat_trackers {
struct {
std::chrono::steady_clock::time_point last_callback_time = std::chrono::steady_clock::now();
T stat_min = std::numeric_limits<T>::max();
T stat_max = std::numeric_limits<T>::min();
T stat_max = std::numeric_limits<T>::lowest();
double stat_total = 0;
uint32_t calls = 0;
} data;
Expand Down
9 changes: 7 additions & 2 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// standard includes
#include <algorithm>
#include <condition_variable>
#include <cstddef>
#include <memory>
#include <mutex>
#include <optional>
Expand Down Expand Up @@ -394,10 +395,10 @@ namespace util {

buf.reserve(data_len);

auto *data = (uint8_t *) &_struct;
auto const *data = reinterpret_cast<std::byte const *>(&_struct);

for (size_t x = 0; x < data_len; ++x) {
buf.push_back(data[x]);
buf.push_back(std::to_integer<uint8_t>(data[x]));
}
}

Expand Down Expand Up @@ -568,6 +569,10 @@ namespace util {
std::string hex;
hex.resize(str_size);

if (begin == end) {
return hex;
}

const char _bits[16] {
'0',
'1',
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_config_consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @file tests/integration/test_config_consistency.cpp
* @brief Test configuration consistency across all configuration files
*/

// test includes
#include "../tests_common.h"

// standard includes
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_external_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @file tests/integration/test_external_commands.cpp
* @brief Integration tests for running external commands with platform-specific validation
*/

// test includes
#include "../tests_common.h"

// standard includes
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_locale_consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @file tests/integration/test_locale_consistency.cpp
* @brief Test locale consistency across configuration files and locale JSON files
*/

// test includes
#include "../tests_common.h"

// standard includes
Expand Down
8 changes: 8 additions & 0 deletions tests/tests_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
*/
#pragma once

// standard includes
#include <memory>
#include <string>
#include <utility>

// Suppress false positive warnings in Boost.Asio on some GCC versions (particularly Arch Linux)
// These are known false positives in Boost.Asio's basic_resolver_results.hpp
#if defined(__GNUC__) && !defined(__clang__)
Expand All @@ -12,7 +17,10 @@
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif

// lib includes
#include <lizardbyte/common/testing.h>

// local includes
#include <src/globals.h>
#include <src/logging.h>
#include <src/platform/common.h>
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* @brief Declarations for SunshineEnvironment.
*/
#pragma once

// test includes
#include "tests_common.h"

struct SunshineEnvironment: testing::Environment {
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* @brief Declarations for SunshineEventListener.
*/
#pragma once

// test includes
#include "tests_common.h"

struct SunshineEventListener: BufferedTestEventListener {
Expand Down
6 changes: 5 additions & 1 deletion tests/tests_log_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
*/
#pragma once

// standard includes
#include <algorithm>
#include <fstream>
#include <regex>
#include <src/logging.h>
#include <string>
#include <string_view>

// local includes
#include <src/logging.h>

namespace log_checker {

Expand Down
2 changes: 2 additions & 0 deletions tests/tests_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @file tests/tests_main.cpp
* @brief Entry point definition.
*/

// test includes
#include "tests_common.h"
#include "tests_environment.h"
#include "tests_events.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/platform/linux/test_wayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* @brief Test Wayland output mode selection.
*/
#ifdef SUNSHINE_BUILD_WAYLAND
// test includes
#include "../../../tests_common.h"

// local includes
#include <src/platform/linux/wayland.h>

TEST(WaylandMonitorTest, IgnoresNonCurrentModesAroundCurrentMode) {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/platform/test_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
* @file tests/unit/platform/test_common.cpp
* @brief Test src/platform/common.*.
*/

// test includes
#include "../../tests_common.h"

// lib includes
#include <boost/asio/ip/host_name.hpp>

// local includes
#include <src/platform/common.h>

TEST(HostnameTests, TestAsioEquality) {
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/platform/test_virtualhid_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @file tests/unit/platform/test_virtualhid_input.cpp
* @brief Tests for shared libvirtualhid input helpers.
*/

// test includes
#include "../../tests_common.h"

// standard includes
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/platform/windows/test_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
* @brief Tests for Windows audio sink selection and endpoint-change handling.
*/

// test includes
#include "../../../tests_common.h"

#ifdef _WIN32
#include "src/platform/common.h"

// standard includes
#include <cstring>

// platform includes
#include <mmdeviceapi.h>
#include <propsys.h>

// local includes
#include "src/platform/common.h"

namespace platf::audio::tests {
bool sink_device_available(const std::string &sink, IMMDeviceEnumerator *device_enum);
bool microphone_available(const std::string &assigned_sink, const std::string &configured_sink, IMMDeviceEnumerator *device_enum);
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/platform/windows/test_utf_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
* @file tests/unit/platform/windows/test_utf_utils.cpp
* @brief Test src/platform/windows/utf_utils.cpp UTF conversion functions.
*/

// test includes
#include "../../../tests_common.h"

// standard includes
#include <iostream>
#include <string>

#ifdef _WIN32
#include <src/platform/windows/utf_utils.h>
// platform includes
#include <Windows.h>

// local includes
#include <src/platform/windows/utf_utils.h>
#endif

#ifdef _WIN32
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
* @file tests/unit/test_audio.cpp
* @brief Test src/audio.*.
*/

// test includes
#include "../tests_common.h"

// local includes
#include <src/audio.h>

using namespace audio;
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_confighttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* verify that the confighttp functions work correctly end-to-end.
*/

// test imports
// test includes
#include "../tests_common.h"

// standard includes
Expand All @@ -20,12 +20,12 @@
#include <thread>
#include <utility>

// lib imports
// lib includes
#include <Simple-Web-Server/client_https.hpp>
#include <Simple-Web-Server/crypto.hpp>
#include <Simple-Web-Server/server_https.hpp>

// local imports
// local includes
#include <src/config.h>
#include <src/confighttp.h>
#include <src/crypto.h>
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* @file tests/unit/test_crypto.cpp
* @brief Test src/crypto.*.
*/
// test imports
// test includes
#include "../tests_common.h"

// lib imports
// lib includes
#include <openssl/x509.h>

// local imports
// local includes
#include <src/crypto.h>

TEST(CryptoTest, GeneratedCredentialsExposeSubjectAndVerifySignatures) {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_display_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
* @file tests/unit/test_display_device.cpp
* @brief Test src/display_device.*.
*/

// test includes
#include "../tests_common.h"

// standard includes
#include <format>

// local includes
#include <src/config.h>
#include <src/display_device.h>
#include <src/rtsp.h>
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_entry_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* @file tests/unit/test_entry_handler.cpp
* @brief Test src/entry_handler.*.
*/

// test includes
#include "../tests_common.h"
#include "../tests_log_checker.h"

// local includes
#include <src/entry_handler.h>

TEST(EntryHandlerTests, LogPublisherDataTest) {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_file_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
* @file tests/unit/test_file_handler.cpp
* @brief Test src/file_handler.*.
*/

// test includes
#include "../tests_common.h"

// standard includes
#include <format>

// local includes
#include <src/file_handler.h>

struct FileHandlerParentDirectoryTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_http_pairing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* @brief Test src/nvhttp.cpp HTTP pairing process
*/

// test includes
#include "../tests_common.h"

// local includes
#include <src/nvhttp.h>

using namespace nvhttp;
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_httpcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* @file tests/unit/test_httpcommon.cpp
* @brief Test src/httpcommon.*.
*/
// test imports
// test includes
#include "../tests_common.h"

// lib imports
// lib includes
#include <curl/curl.h>

// local imports
// local includes
#include <src/httpcommon.h>

struct UrlEscapeTest: BaseTest, testing::WithParamInterface<std::tuple<std::string, std::string>> {};
Expand Down
Loading