-
Notifications
You must be signed in to change notification settings - Fork 1
Out Diff
Compares two sets of strings and highlights the differences in hexadecimal output.
Out-Diff [-Difference] <String[]> [-Reference] <String[]> [[-DifferenceAnsi] <String>] [[-AnsiReset] <String>]
[[-DiffIndicator] <String>] [[-EqualIndicator] <String>] [-AsVerbose] [-NoHeader] [[-ReferenceLabel] <String>]
[[-DifferenceLabel] <String>] [[-ReferenceLabelAnsi] <String>] [[-DifferenceLabelAnsi] <String>] [-PassThru]
[<CommonParameters>]
The Out-Diff command compares two sets of strings, $Difference and $Reference. Outputs the result using hexadecimal output and highlights the differences between the two sets of strings in a side-by-side format, making it easier to spot discrepancies at a byte level.
Its main intended use is in unit tests when comparing large text masses that can have small, normally invisible differences, such as an extra or missing line feed or new line character.
The command supports ANSI escape sequences for coloring the differences between the actual and expected strings. The default color for differences is red. The command defaults to outputting the result as informational messages, but it also supports displaying the differences using the Write-Verbose cmdlet or returning the result as output.
$actual = "Hello", "World"
$expected = "Hello", "Universe"
Out-Diff -Difference $actual -Reference $expected
This example compares the actual strings "Hello" and "World" with the expected strings "Hello" and "Universe". The function displays the differences between the two sets of strings.
Specifies the ANSI escape sequence to reset the formatting. The default value is '0m'.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: 0m
Accept pipeline input: False
Accept wildcard characters: FalseSwitch parameter. If specified, the differences are displayed using the Write-Verbose cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the set of strings to compare against the reference strings. This parameter is mandatory.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the ANSI escape sequence for controlling how the difference is highlighted. The default value is '30;31m' (red).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: 30;31m
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the label for the difference strings. The default value is 'But was:'. The label should be no longer than 65 characters.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: But was:
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the ANSI escape sequence for controlling the look of the difference label. The default value is '4m' (underline).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: 4m
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the indicator to display when there is a differences between the strings. The default value is '!='.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: !=
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the indicator to display when there is equality between the strings. The default value is '!='.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: ==
Accept pipeline input: False
Accept wildcard characters: FalseSwitch parameter. If specified, the header message is not displayed.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSwitch parameter. If specified, the output is returned as an array of strings.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the set of reference strings to compare against the difference strings. This parameter is mandatory.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the label for the reference strings. The default value is 'Expected:'. The label should be no longer than 65 characters.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: Expected:
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the ANSI escape sequence for controlling the look of the reference label. The default value is '4m' (underline).
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 9
Default value: 4m
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
- Assert-GitLocalChange
- Assert-GitRemote
- Assert-IPv4Address
- Clear-AnsiSequence
- ConvertTo-AnsiSequence
- ConvertTo-AnsiString
- ConvertTo-DifferenceString
- ConvertTo-RelativePath
- Disable-CursorShortcutCode
- Get-ClassAst
- Get-ClassResourceAst
- Get-GitBranchCommit
- Get-GitLocalBranchName
- Get-GitRemote
- Get-GitRemoteBranch
- Get-GitTag
- Get-LinkLayerAddress
- Get-ModuleByVersion
- Get-ModuleFileSha
- Get-ModuleVersion
- Get-NumericalSequence
- Get-PSReadLineHistory
- Get-TextOffset
- Install-ModulePatch
- Invoke-Git
- Invoke-PesterJob
- New-GitTag
- New-SamplerGitHubReleaseTag
- Out-Difference
- Pop-VMLatestSnapshot
- Push-GitTag
- Receive-GitBranch
- Remove-GitTag
- Remove-History
- Remove-PSHistory
- Remove-PSReadLineHistory
- Rename-GitLocalBranch
- Rename-GitRemote
- Request-GitTag
- Resolve-DnsName
- Resume-GitRebase
- Send-WakeOnLan
- Split-StringAtIndex
- Start-GitRebase
- Stop-GitRebase
- Switch-GitLocalBranch
- Test-FileHash
- Test-GitLocalChanges
- Test-GitRemote
- Test-GitRemoteBranch
- Test-IPv4Address
- Update-GitLocalBranch
- Update-RemoteTrackingBranch