-
-
Notifications
You must be signed in to change notification settings - Fork 0
✅ increase unit test coverage #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughConverts DecodeTests to a public partial class, adopts generated regex in tests, standardizes shared test data and UTF-8 literals, and adds numerous new unit tests across decode, encode, and utility behaviors. Minor const and forward-declaration cleanups applied. No production code changed; all edits are within test projects. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
==========================================
+ Coverage 94.92% 98.25% +3.33%
==========================================
Files 15 15
Lines 1379 1379
Branches 391 391
==========================================
+ Hits 1309 1355 +46
+ Misses 70 24 -46
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…filter exceptions
…t method behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
QsNet.Tests/DecodeTests.cs (1)
1920-1922
: Compile error: invalid lambda declaration (var action = void () => ...
)C# does not allow
void
in lambda literals withvar
. Use anAction
delegate.Apply:
- var action = void () => - parsed = Qs.Decode(str.ToString(), new DecodeOptions { Depth = depth }); + Action action = () => + parsed = Qs.Decode(str.ToString(), new DecodeOptions { Depth = depth });
🧹 Nitpick comments (6)
QsNet.Tests/EncodeTests.cs (3)
1875-1875
: C# 11 UTF‑8 string literals used"test"u8.ToArray() and similar require LangVersion >= 11.0. Confirm the test project’s LangVersion; otherwise replace with Encoding.UTF8.GetBytes(...).
If you need a fallback, change e.g.:
- { "a", "test"u8.ToArray() } + { "a", Encoding.UTF8.GetBytes("test") }Also applies to: 1884-1884, 2442-2442, 2473-2473, 2485-2485, 3265-3265, 4377-4377
364-364
: Remove early returns; local helpers don’t execute unless calledThe return; statements used to “guard” local function declarations are unnecessary and can confuse readers and coverage tools. Local functions are inert unless invoked. Consider removing these returns and keeping helpers below or above within the same method.
- return; + // keep local helper below; not executed unless calledAlso applies to: 2183-2183, 2259-2259
21-26
: No LangVersion changes needed; alias duplicate static arrays
Test project targets net8.0 (C# 12 by default). ValueArray duplicates Value and Value1 duplicates ValueArray0; consider:- private static readonly string[] ValueArray = ["b", "c"]; + private static readonly string[] ValueArray = Value; - private static readonly string[] Value1 = ["b"]; + private static readonly string[] Value1 = ValueArray0;QsNet.Tests/DecodeTests.cs (3)
19-19
: Partial class name consistencyClass renamed to
DecodeTest
and markedpartial
. Ensure other partials use the exact same name and namespace, or rename to match existingDecodeTests
if that’s the intended shared type.
2036-2044
: Earlyreturn;
leaves unreachable code in testsThe
return;
before local function declarations compiles, but it leaves the declarations in an unreachable region. Consider moving local functions above thereturn;
, or hoist them to private static helpers to keep test bodies clean.Also applies to: 2185-2192
4820-4822
: [GeneratedRegex] requires net7+; consider multi-target guardTests use
[GeneratedRegex]
without a NETSTANDARD2_0 fallback. If the test project multi-targets, mirror the#if NETSTANDARD2_0 ... else ...
pattern used in production to keep compatibility.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
QsNet.Tests/DecodeTests.cs
(11 hunks)QsNet.Tests/EncodeTests.cs
(20 hunks)QsNet.Tests/SentinelExtensionsTests.cs
(1 hunks)QsNet.Tests/UtilsTests.cs
(6 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
QsNet.Tests/UtilsTests.cs (2)
QsNet/Internal/Utils.cs (15)
Utils
(20-1227)List
(695-723)Dictionary
(546-687)Dictionary
(905-911)Dictionary
(918-927)Dictionary
(934-946)Dictionary
(999-1002)Dictionary
(1010-1076)Dictionary
(1105-1226)Merge
(69-268)Encode
(381-502)Decode
(510-538)InterpretNumericEntities
(808-898)ReferenceEqualityComparer
(1232-1249)ReferenceEqualityComparer
(1236-1238)QsNet/Models/Undefined.cs (3)
Undefined
(6-37)Undefined
(11-13)Undefined
(33-36)
QsNet.Tests/DecodeTests.cs (3)
QsNet/Models/DecodeOptions.cs (4)
DecodeOptions
(40-321)DecodeOptions
(49-63)DecodeOptions
(274-320)Decode
(203-214)QsNet/Internal/Utils.cs (13)
Decode
(510-538)Dictionary
(546-687)Dictionary
(905-911)Dictionary
(918-927)Dictionary
(934-946)Dictionary
(999-1002)Dictionary
(1010-1076)Dictionary
(1105-1226)Utils
(20-1227)GeneratedRegex
(41-42)GeneratedRegex
(56-57)Regex
(36-39)Regex
(51-54)QsNet/Internal/Decoder.cs (3)
ParseKeys
(470-488)Dictionary
(107-271)Decoder
(16-761)
QsNet.Tests/EncodeTests.cs (6)
QsNet/Qs.cs (3)
Dictionary
(30-117)Qs
(20-280)Encode
(126-279)QsNet/Internal/Utils.cs (10)
Dictionary
(546-687)Dictionary
(905-911)Dictionary
(918-927)Dictionary
(934-946)Dictionary
(999-1002)Dictionary
(1010-1076)Dictionary
(1105-1226)Encode
(381-502)List
(695-723)Utils
(20-1227)QsNet/Internal/Encoder.cs (2)
Encode
(42-429)Encoder
(14-430)QsNet/Models/EncodeOptions.cs (3)
EncodeOptions
(33-282)EncodeOptions
(42-55)EncodeOptions
(235-281)QsNet/Internal/SideChannelFrame.cs (1)
SideChannelFrame
(11-37)QsNet/Models/Filter.cs (4)
IterableFilter
(36-51)IterableFilter
(42-45)FunctionFilter
(15-30)FunctionFilter
(21-24)
🔇 Additional comments (2)
QsNet.Tests/SentinelExtensionsTests.cs (1)
35-35
: Good change: make invalid enum constantUsing a const for the invalid sentinel enforces immutability and intent. LGTM.
QsNet.Tests/EncodeTests.cs (1)
209-214
: Nice additions covering primitives, materialized indices, filters, and dictionariesThese tests tighten behavior around non-list enumerables, IterableFilter index handling, non-generic IDictionary, filter exception handling, hashtable conversion, and OOR indices. Good coverage expansion.
Also applies to: 216-222, 224-240, 242-248, 250-258, 260-271, 273-285, 287-299, 300-316
This pull request expands and improves the test coverage for both decoding and encoding functionality in
QsNet.Tests
, while also introducing several code quality improvements. The main changes include adding new test cases for edge scenarios (such as strict depth handling, filter behavior, and encoding of various data types), refactoring for clarity, and making use of modern C# features for conciseness and maintainability.Decode tests:
DecodeTests.cs
).const
for query strings and encoded values, and introduced a[GeneratedRegex]
partial method for regex test reuse. [1] [2] [3] [4]Encode tests:
"test"u8.ToArray()
) for byte arrays. [1] [2] [3]General improvements:
These changes significantly enhance the reliability of the test suite and ensure robust validation of both typical and edge-case behaviors in the library.
Summary by CodeRabbit