Skip to content

Add 48 C++ MSTest tests for LightSwitch#46934

Open
crutkas wants to merge 4 commits intomicrosoft:mainfrom
crutkas:split/lightswitch-tests
Open

Add 48 C++ MSTest tests for LightSwitch#46934
crutkas wants to merge 4 commits intomicrosoft:mainfrom
crutkas:split/lightswitch-tests

Conversation

@crutkas
Copy link
Copy Markdown
Member

@crutkas crutkas commented Apr 12, 2026

Summary

48 new TEST_METHODs covering LightSwitch:

  • ShouldBeLight schedule logic with fixed times and midnight wraparound
  • Sunrise/sunset daylight-duration validation (timezone-wrap safe)
  • ScheduleMode enum serialization round-trip
  • Config defaults

Split from #46905 (5/7) — see that PR for full context.

Files Changed (7)

  • src/modules/LightSwitch/UnitTests/LightSwitchTests.cpp (new)
  • src/modules/LightSwitch/UnitTests/UnitTests-LightSwitch.vcxproj (new)
  • src/modules/LightSwitch/UnitTests/UnitTests-LightSwitch.vcxproj.filters (new)
  • src/modules/LightSwitch/UnitTests/pch.cpp (new)
  • src/modules/LightSwitch/UnitTests/pch.h (new)
  • PowerToys.slnx (modified — +1 project ref in /modules/LightSwitch/Tests/)
  • .github/actions/spell-check/expect.txt (modified)

ShouldBeLight schedule logic with fixed times and midnight wraparound,
sunrise/sunset daylight-duration validation (timezone-wrap safe),
ScheduleMode enum serialization round-trip, and config defaults.

Split from PR microsoft#46905 (5/7)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@crutkas crutkas added the Area-Tests issues that relate to tests label Apr 12, 2026
@crutkas
Copy link
Copy Markdown
Member Author

crutkas commented Apr 12, 2026

/azp run

@crutkas crutkas added the Needs-Review This Pull Request awaits the review of a maintainer. label Apr 12, 2026
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

An engineer--not a computer--needs to verify each of these test cases to ensure that they are worthwhile and on-target.

- Created LightSwitchTypes.h with ScheduleMode, ToString/FromString, LightSwitchConfig
- Modified LightSwitchSettings.h to include LightSwitchTypes.h
- Removed copy-pasted definitions from test file (20 tests now test real code)
- Extracted CoordinatesAreValid to LightSwitchUtils.h as free function
- Added 6 CoordinatesAreValid tests
- Added 2 polar-region SunCalc edge case tests (documenting -1 sentinel bug)
- Added deep comments to all 56 test methods

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
// Product code: LightSwitchTypes.h — LightSwitchConfig::latitude default
// What: Verifies latitude defaults to "0.0" (null island sentinel)
// Why: CoordinatesAreValid rejects (0,0) — forces user to configure location
// Risk: Unconfigured users accidentally get sunset times for null island
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.

Unrecognized words (1)

Unconfigured

These words are not needed and should be removed diu IPREVIEW ITHUMBNAIL LPCFHOOKPROC LUMA MAXDWORD MRT suntimes timespan VSync

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:crutkas/autoUpgradeAttempt.git repository
on the split/lightswitch-tests branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/cfb6f7e75bbfc89c71eaa30366d0c166f1bd9c8c/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/24324954899/attempts/1' &&
git commit -m 'Update check-spelling metadata'
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

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

Labels

Area-Tests issues that relate to tests Needs-Review This Pull Request awaits the review of a maintainer.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants