Skip to content

Add Peek.Common unit tests (MathHelper, PathHelper)#49105

Open
crutkas wants to merge 1 commit into
mainfrom
crutkas/peek-common-tests
Open

Add Peek.Common unit tests (MathHelper, PathHelper)#49105
crutkas wants to merge 1 commit into
mainfrom
crutkas/peek-common-tests

Conversation

@crutkas

@crutkas crutkas commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Adds a Peek.Common.UnitTests project (MSTest) with unit coverage for Peek.Common.Helpers:

  • MathHelper.Modulo — positive/zero results, negative-dividend wrap-around, large values, and the new non-positive-divisor guard.
  • MathHelper.NumberOfDigits — single/multi-digit, negative, and 9/10 & 99/100 boundary values.
  • PathHelper.IsUncPath — standard UNC, subfolders, dotted-server and IP hosts, plus negatives: drive-letter, relative, empty, HTTP URL, ile:// URI, single backslash, and null.

Also adds a small correctness guard to MathHelper.Modulo: a non-positive divisor now throws ArgumentOutOfRangeException instead of silently throwing DivideByZeroException (b == 0) or returning a misleading result (b < 0). Registers the test project in PowerToys.slnx (ARM64 + x64).

37 tests pass locally (x64 Debug).

Context

This is a clean, tests-only split of #46684 (the Peek.Common portion), intentionally without the bundled global dependency bump from that PR. The PowerAccent.Core portion of #46684 was shipped separately in #49104.

Test coverage

Area Tests
MathHelper.Modulo / NumberOfDigits included
PathHelper.IsUncPath included

No production behavior changes beyond the Modulo argument guard, which is covered by the new tests.

Adds a Peek.Common.UnitTests project (MSTest) covering MathHelper.Modulo /
NumberOfDigits and PathHelper.IsUncPath, including negative-dividend,
boundary, UNC, drive-letter, URI, and empty/null edge cases. Adds an
argument guard to MathHelper.Modulo so a non-positive divisor throws
instead of silently dividing by zero, and registers the test project in
PowerToys.slnx.

Tests-only split of #46684 (Peek portion), without the bundled global
dependency bump. 37 tests pass.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Product-Peek Refers to Peek Powertoys label Jul 3, 2026
/// Why: Baseline positive case — the most common UNC format
/// </summary>
[TestMethod]
public void IsUncPath_StandardUncPath_ShouldReturnTrue()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[nit] A data-driven unit test would be more compact.

@jiripolasek

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Peek Refers to Peek Powertoys

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants