Skip to content

test: cover calculator, text transforms, snippets, smart clip and alert rules - #58

Merged
Quost merged 1 commit into
mainfrom
test/pure-logic
Nov 24, 2026
Merged

Quost merged 1 commit into
mainfrom
test/pure-logic

Conversation

@Quost

@Quost Quost commented Nov 23, 2026

Copy link
Copy Markdown
Owner

What changes

Unit tests for user-facing pure logic that had none, found in the codebase audit. There are 5 new test files with about 100 assertions, and no production code changes.

  • CalculatorTests:
    • evaluate covers precedence, parentheses, ^, implicit multiplication, !, sqrt, unary minus, "20% of 340", "200 + 10%", unit conversions, invalid input and 1/0.
    • Also splitConversion, currencyQuery (parsing only, no network), number and format.
  • TextTransformTests:
    • Case conversions (camel, snake, kebab, title, sentence) and accent removal.
    • Line sort, unique and reverse, and the JSON minify/pretty and Base64/URL round-trips.
    • JWT decoding, plus invalid JSON and invalid Base64.
  • SnippetTests: expand, expandWithCursor, fields(in:), and apply(_:values:), which inserts values literally even with $1 or \0 in them.
  • SmartClipTests: parseColor (hex, short hex, rgb, HSL, invalid) and the actions offered for colors, tracking codes, links, e-mail and phone numbers.
  • AlertRulesTests:
    • check(_:now:) with an injected time: a rule fires only after its duration, the timer resets when the condition clears, plus 0-minute and disabled rules and a missing battery value.
    • It uses a plain SystemMonitor() without start(), so no hardware or notifications are involved.

Notes for review

  • Written on a machine that can't build Swift, so every expected value comes from reading the code. CI is the first run. If a case fails, it's most likely one of these:
    • The NSDataDetector cases in SmartClipTests (phone number, the exact ["link", "qr"] list).
    • The unit-symbol strings in CalculatorTests ("100 °C", "1000 MB").
  • Results only use integers, so nothing depends on the locale's decimal separator.

🤖 Generated with Claude Code

@Quost
Quost merged commit a0aeff8 into main Nov 24, 2026
15 checks passed
@Quost
Quost deleted the test/pure-logic branch November 24, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant