-
-
Notifications
You must be signed in to change notification settings - Fork 0
✅ increase coverage #40
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
920fe0d
:white_check_mark: add unit tests for ListFormat generators
techouse 49eca19
:white_check_mark: add unit tests for Utils.merge, encode, and helper…
techouse 162cdd7
:white_check_mark: add test for legacy decoder fallback in DecodeOptions
techouse f3e2e4d
:recycle: improve boundary string construction in utils_additional_test
techouse 4b48728
:white_check_mark: add test for deprecated decoder in DecodeOptions
techouse 1731596
:white_check_mark: add targeted unit tests for QS.decode edge cases
techouse 3665669
:white_check_mark: add targeted unit tests for QS.decode edge cases
techouse d30db5f
:white_check_mark: add tests for Utils.merge and encode surrogate han…
techouse fb64587
:white_check_mark: add test for merging maps with scalar targets in U…
techouse 3eb8a1e
:recycle: refactor encode logic to handle dot encoding for root primi…
techouse faf59cd
:white_check_mark: add tests for decode depth remainder wrapping scen…
techouse e42be8f
:white_check_mark: add tests for encoding edge cases in QS.encode
techouse a4d8cae
:white_check_mark: add additional tests for QS.encode covering empty …
techouse 4775b94
:white_check_mark: add tests for surrogate and charset edge cases in …
techouse 5d8c95e
:rewind: revert changes
techouse f90c1db
:white_check_mark: add tests for MapBase implementation with throwing…
techouse 62e82a0
:white_check_mark: update test for QS.encode to allow flexible encodi…
techouse e5b089d
:pencil2: change return type of operator [] to non-nullable String in…
techouse 64bca00
:white_check_mark: update tests in encode_edge_cases_test.dart to use…
techouse 7e11b30
:white_check_mark: update tests in encode_edge_cases_test.dart to ver…
techouse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import 'package:qs_dart/qs_dart.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| void main() { | ||
| group('ListFormat generators', () { | ||
| test('brackets format appends empty brackets', () { | ||
| expect(ListFormat.brackets.generator('foo'), equals('foo[]')); | ||
| }); | ||
|
|
||
| test('comma format keeps prefix untouched', () { | ||
| expect(ListFormat.comma.generator('foo'), equals('foo')); | ||
| }); | ||
|
|
||
| test('repeat format reuses the prefix', () { | ||
| expect(ListFormat.repeat.generator('foo'), equals('foo')); | ||
| }); | ||
|
|
||
| test('indices format injects the element index', () { | ||
| expect(ListFormat.indices.generator('foo', '2'), equals('foo[2]')); | ||
| }); | ||
|
|
||
| test('toString mirrors enum name', () { | ||
| expect(ListFormat.indices.toString(), equals('indices')); | ||
| }); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import 'dart:collection'; | ||
|
|
||
| import 'package:qs_dart/qs_dart.dart'; | ||
| import 'package:qs_dart/src/utils.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| void main() { | ||
| group('Utils.merge edge branches', () { | ||
| test('normalizes to map when Undefined persists and parseLists is false', | ||
| () { | ||
| final result = Utils.merge( | ||
| [const Undefined()], | ||
| const [Undefined()], | ||
| const DecodeOptions(parseLists: false), | ||
| ); | ||
|
|
||
| final splay = result as SplayTreeMap; | ||
| expect(splay.isEmpty, isTrue); | ||
| }); | ||
|
|
||
| test('combines non-iterable scalars into a list pair', () { | ||
| expect(Utils.merge('left', 'right'), equals(['left', 'right'])); | ||
| }); | ||
|
|
||
| test('combines scalar and iterable respecting Undefined stripping', () { | ||
| final result = Utils.merge( | ||
| 'seed', | ||
| ['tail', const Undefined()], | ||
| ); | ||
| expect(result, equals(['seed', 'tail'])); | ||
| }); | ||
|
|
||
| test('wraps custom iterables in a list when merging scalar sources', () { | ||
| final Iterable<String> iterable = Iterable.generate(1, (i) => 'it-$i'); | ||
|
|
||
| final result = Utils.merge(iterable, 'tail'); | ||
|
|
||
| expect(result, isA<List>()); | ||
| final listResult = result as List; | ||
| expect(listResult.first, same(iterable)); | ||
| expect(listResult.last, equals('tail')); | ||
| }); | ||
|
|
||
| test('promotes iterable targets to index maps before merging maps', () { | ||
| final result = Utils.merge( | ||
| [const Undefined(), 'keep'], | ||
| {'extra': 1}, | ||
| ) as Map<String, dynamic>; | ||
|
|
||
| expect(result, equals({'1': 'keep', 'extra': 1})); | ||
| }); | ||
|
|
||
| test('wraps scalar targets into heterogeneous lists when merging maps', () { | ||
| final result = Utils.merge( | ||
| 'seed', | ||
| {'extra': 1}, | ||
| ) as List; | ||
|
|
||
| expect(result.first, equals('seed')); | ||
| expect(result.last, equals({'extra': 1})); | ||
| }); | ||
| }); | ||
|
|
||
| group('Utils.encode surrogate handling', () { | ||
| const int segmentLimit = 1024; | ||
|
|
||
| String buildBoundaryString() { | ||
| final high = String.fromCharCode(0xD83D); | ||
| final low = String.fromCharCode(0xDE00); | ||
| return '${'a' * (segmentLimit - 1)}$high${low}tail'; | ||
| } | ||
|
|
||
| test('avoids splitting surrogate pairs across segments', () { | ||
| final encoded = Utils.encode(buildBoundaryString()); | ||
| expect(encoded.startsWith('a' * (segmentLimit - 1)), isTrue); | ||
| expect(encoded, contains('%F0%9F%98%80')); | ||
| expect(encoded.endsWith('tail'), isTrue); | ||
| }); | ||
|
|
||
| test('encodes high-and-low surrogate pair to four-byte UTF-8', () { | ||
| final emoji = String.fromCharCodes([0xD83D, 0xDE01]); | ||
| expect(Utils.encode(emoji), equals('%F0%9F%98%81')); | ||
| }); | ||
|
|
||
| test('encodes lone high surrogate as three-byte sequence', () { | ||
| final loneHigh = String.fromCharCode(0xD83D); | ||
| expect(Utils.encode(loneHigh), equals('%ED%A0%BD')); | ||
| }); | ||
|
|
||
| test('encodes lone low surrogate as three-byte sequence', () { | ||
| final loneLow = String.fromCharCode(0xDC00); | ||
| expect(Utils.encode(loneLow), equals('%ED%B0%80')); | ||
| }); | ||
| }); | ||
|
|
||
| group('Utils helpers', () { | ||
| test('isNonNullishPrimitive treats Uri based on skipNulls flag', () { | ||
| final emptyUri = Uri.parse(''); | ||
| expect(Utils.isNonNullishPrimitive(emptyUri), isTrue); | ||
| expect(Utils.isNonNullishPrimitive(emptyUri, true), isFalse); | ||
| final populated = Uri.parse('https://example.com'); | ||
| expect(Utils.isNonNullishPrimitive(populated, true), isTrue); | ||
| }); | ||
|
|
||
| test('interpretNumericEntities handles astral plane code points', () { | ||
| expect(Utils.interpretNumericEntities('😀'), equals('😀')); | ||
| }); | ||
|
|
||
| test('createIndexMap materializes non-List iterables', () { | ||
| final iterable = Iterable.generate(3, (i) => i * 2); | ||
| expect( | ||
| Utils.createIndexMap(iterable), | ||
| equals({'0': 0, '1': 2, '2': 4}), | ||
| ); | ||
| }); | ||
| }); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.