Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected override void ProcessRecord()
// I am using TotalCount - countToRead so that I don't
// have to worry about overflow

if ((TotalCount > 0) && (TotalCount - countToRead < countRead))
if ((TotalCount > 0) && (countToRead == 0 || (TotalCount - countToRead < countRead)))
{
countToRead = TotalCount - countRead;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ baz
$expected[1] = $thirdLine
Compare-Object -ReferenceObject $expected -DifferenceObject $result | Should -BeNullOrEmpty
}
It "Should return the same number of first lines as set in -TotalCount at one time for -ReadCount 0" {
$result = Get-Content -Path $testPath -TotalCount 3 -ReadCount 0
$result.Length | Should -Be 3
$expected = $firstLine,$secondLine,$thirdLine
Compare-Object -ReferenceObject $expected -DifferenceObject $result | Should -BeNullOrEmpty
}
It "A warning should be emitted if both -AsByteStream and -Encoding are used together" {
[byte[]][char[]]"test" | Set-Content -Encoding Unicode -AsByteStream "${TESTDRIVE}\bfile.txt" -WarningVariable contentWarning *> $null
$contentWarning.Message | Should -Match "-AsByteStream"
Expand Down