Skip to content

fix: iterator/stat utility edge cases and add tests - #5308

Merged
ReenigneArcher merged 3 commits into
LizardByte:masterfrom
dasepmoch:test/add-utility-round-robin-stat-trackers-tests
Sep 2, 2026
Merged

ReenigneArcher merged 3 commits into
LizardByte:masterfrom
dasepmoch:test/add-utility-round-robin-stat-trackers-tests

Conversation

@dasepmoch

@dasepmoch dasepmoch commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes correctness and safety issues discovered while expanding unit coverage for the round-robin iterator, statistics tracker, and utility helpers.

  • Compare round-robin iterators by position instead of the value at that position, preventing duplicate values at different positions from comparing equal.
  • Implement the positional comparison required by the round-robin iterator's relational operators.
  • Constrain the round-robin iterator and its factory to random-access iterators, matching the operations and iterator category they expose.
  • Initialize the maximum statistic with std::numeric_limits<T>::lowest(), allowing negative floating-point samples to be tracked correctly.
  • Handle empty ranges in hex_vec() without decrementing an invalid end iterator.
  • Add regression coverage for the corrected behavior and broader coverage for the existing round-robin, statistics, and utility APIs.
  • Normalize include-section comments and direct includes across the test sources to match project style.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@ReenigneArcher ReenigneArcher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Always glad to have more tests added!

Looks pretty good, but could you fix the sonar reported sonar issues as well as adjust the style of the comments mentioned below.

Also, please update the PR to use the correct template. You can find it at https://github.com/LizardByte/.github/blob/master/.github/pull_request_template.md?plain=1

Comment thread tests/unit/test_round_robin.cpp Outdated
Comment thread tests/unit/test_stat_trackers.cpp Outdated
@ReenigneArcher
ReenigneArcher force-pushed the test/add-utility-round-robin-stat-trackers-tests branch from 6da22e1 to c53fb9c Compare September 2, 2026 01:09
@LizardByte LizardByte deleted a comment from sonarqubecloud Bot Sep 2, 2026
@ReenigneArcher
ReenigneArcher force-pushed the test/add-utility-round-robin-stat-trackers-tests branch from 9a036b8 to 68bfcfa Compare September 2, 2026 02:50
Corrected core logic in `round_robin`, `stat_trackers`, and `utility`: round-robin equality now compares iterator position (not dereferenced value), ordering support was added, and the iterator is constrained to random-access types; `min_max_avg_tracker` now initializes max with `lowest()` to handle negative values correctly; and hex conversion now safely handles empty ranges.

Tests were broadly reorganized and tightened to match include/style conventions and to cover the behavior changes, including duplicate-value iterator comparisons, ordering semantics, negative stat tracking, and empty hex-vector handling.
@ReenigneArcher
ReenigneArcher force-pushed the test/add-utility-round-robin-stat-trackers-tests branch from 68bfcfa to bf5b5c2 Compare September 2, 2026 03:06
@ReenigneArcher ReenigneArcher changed the title test(unit): add tests for utility, round_robin, and stat_trackers fix: iterator/stat utility edge cases and add tests Sep 2, 2026
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

ReenigneArcher
ReenigneArcher previously approved these changes Sep 2, 2026
@ReenigneArcher
ReenigneArcher force-pushed the test/add-utility-round-robin-stat-trackers-tests branch from 0021a3d to 1ae76a1 Compare September 2, 2026 03:43
@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

@ReenigneArcher

Copy link
Copy Markdown
Member

Thanks for the PR! While reviewing the changes I discovered some edge cases in the src code that needed to be fixed, so the tests are already proving to be useful.

I've pushed additional changes to this PR to address those edge cases, as well as a small style change for the tests.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.63%. Comparing base (f61bf77) to head (1ae76a1).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5308      +/-   ##
==========================================
+ Coverage   35.12%   35.63%   +0.50%     
==========================================
  Files         104      104              
  Lines       25406    25508     +102     
  Branches    11211    11240      +29     
==========================================
+ Hits         8925     9090     +165     
+ Misses      13543    13419     -124     
- Partials     2938     2999      +61     
Flag Coverage Δ
Archlinux 0.00% <0.00%> (ø)
FreeBSD-amd64 21.69% <100.00%> (+0.89%) ⬆️
Homebrew-macos-14 33.26% <85.71%> (+0.77%) ⬆️
Homebrew-macos-15 33.92% <85.71%> (+0.79%) ⬆️
Homebrew-macos-26 34.06% <100.00%> (+0.82%) ⬆️
Homebrew-ubuntu-24.04 22.50% <66.66%> (+0.62%) ⬆️
Linux-AppImage 21.92% <66.66%> (+0.63%) ⬆️
Windows-AMD64 27.77% <66.66%> (+0.68%) ⬆️
Windows-ARM64 23.85% <100.00%> (+0.96%) ⬆️
macOS-arm64 28.63% <100.00%> (+1.19%) ⬆️
macOS-x86_64 29.25% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/round_robin.h 100.00% <100.00%> (+100.00%) ⬆️
src/stat_trackers.h 100.00% <100.00%> (+52.63%) ⬆️
src/utility.h 85.54% <100.00%> (+9.31%) ⬆️

... and 25 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f61bf77...1ae76a1. Read the comment docs.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Last Updated 2026-09-02 12:57:19 UTC
Source Run CI Run #5244
Commit 1ae76a1e37e46a2323aa746c213075946b6deb7f

Screenshot Comparison

PR #5308 screenshots vs screenshots baseline.

Matrix: AppImage

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-AMD64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-ARM64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-arm64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-x86_64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

@ReenigneArcher ReenigneArcher added the ai PR has signs of heavy ai usage (either indicated by user or assumed) label Sep 2, 2026
@ReenigneArcher
ReenigneArcher merged commit 3841ac5 into LizardByte:master Sep 2, 2026
118 of 120 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai PR has signs of heavy ai usage (either indicated by user or assumed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants