Skip to content

Add comprehensive array and dictionary tests for ConvertTo-Json - #26742

Merged
Dongbo Wang (daxian-dbw) merged 5 commits into
PowerShell:masterfrom
yotsuda:add-convertto-json-array-dictionary-tests
Feb 6, 2026
Merged

Dongbo Wang (daxian-dbw) merged 5 commits into
PowerShell:masterfrom
yotsuda:add-convertto-json-array-dictionary-tests

Conversation

@yotsuda

Copy link
Copy Markdown
Contributor

PR Summary

Add comprehensive array and dictionary tests for ConvertTo-Json (Phase 2).

PR Context

This is a follow-up to #26736. Per Ilya (@iSazonov)'s suggestion in #26639, comprehensive tests are being submitted as separate PRs for each phase.

PR Checklist

Tests Added

The following array and dictionary tests are added to ConvertTo-Json.Tests.ps1:

Context Tests Description
Array basic serialization 7 empty, single, multi-element, string, typed, null elements
Nested arrays 6 2D, 3D, jagged, empty nested, depth limit
Array with mixed content types 4 mixed scalars, nested, hashtable/PSCustomObject elements
Array ETS properties 2 single and multiple ETS properties
Hashtable basic serialization 4 empty, single key, null value, various scalar types
OrderedDictionary serialization 2 order preservation, large dictionary
Nested dictionaries 5 nested, deeply nested, depth limit, array values
Dictionary key types 4 string, special chars, unicode, empty string keys
Dictionary with complex values 5 DateTime, Guid, enum, PSCustomObject values
Dictionary ETS properties 2 hashtable and OrderedDictionary ETS
Generic Dictionary types 2 Dictionary<string,int>, SortedDictionary
Array of dictionaries 2 via Pipeline and InputObject
Dictionary with array values 3 array values, nested arrays, empty arrays

Total: 48 new tests

Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Json.Tests.ps1 Outdated
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Json.Tests.ps1 Outdated
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Json.Tests.ps1 Outdated
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Json.Tests.ps1 Outdated
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Json.Tests.ps1 Outdated
@iSazonov Ilya (iSazonov) added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Feb 4, 2026
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/ConvertTo-Json.Tests.ps1 Outdated
@iSazonov Ilya (iSazonov) added the Approved-LowRisk Indicate a PR has been approved and can be merged after a quick review of another maintainer. label Feb 4, 2026
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Feb 5, 2026

Copy link
Copy Markdown
Member

Yoshifumi (@yotsuda) or Ilya (@iSazonov), can either of you please resolve the conflict? I won't be able to approve and merge the PR if I resolve it.
The conflict is caused by merging #26736

Yoshifumi (yotsuda) and others added 4 commits February 6, 2026 09:52
- Use IPAddress instead of integer for depth limit tests to clearly
  verify ToString() is called when depth is exceeded
- Use Unicode escape format for unicode key test
- Add array versions of DateTime, Guid, and enum serialization tests
- Remove duplicate 'array with hashtable elements' test

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Change IP from 10.0.0.1 to 192.168.1.1 for consistency with previous test
- Replace BeLike/Not-BeExactly with BeExactly using actual JSON output

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@yotsuda
Yoshifumi (yotsuda) force-pushed the add-convertto-json-array-dictionary-tests branch from 117c0bc to 78b2ae0 Compare February 6, 2026 01:18
@yotsuda

Copy link
Copy Markdown
Contributor Author

Dongbo Wang (@daxian-dbw) Rebased onto master to resolve the conflict.

@yotsuda
Yoshifumi (yotsuda) marked this pull request as ready for review February 6, 2026 13:07
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 4382544 into PowerShell:master Feb 6, 2026
36 checks passed
@yotsuda
Yoshifumi (yotsuda) deleted the add-convertto-json-array-dictionary-tests branch February 10, 2026 00:09
@iSazonov Ilya (iSazonov) self-assigned this Feb 21, 2026
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved-LowRisk Indicate a PR has been approved and can be merged after a quick review of another maintainer. CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants