Fix wrong behavior when reading text

Also add another 'file read error' status.

Closes #19254.
PR #19262.
This commit is contained in:
Chocobo1 2023-07-02 13:23:20 +08:00 committed by GitHub
parent 08a771468d
commit 80791e328d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 11 deletions

2
test/testdata/crlf.txt vendored Normal file
View file

@ -0,0 +1,2 @@

View file

@ -77,6 +77,13 @@ private slots:
QCOMPARE(readResult.value(), size10Data);
}
{
const Path crlfFile = testFolder / Path(u"crlf.txt"_s);
const auto readResult = Utils::IO::readFile(crlfFile, -1, QIODevice::Text);
QCOMPARE(readResult.has_value(), true);
QCOMPARE(readResult.value(), "\n\n");
}
{
const Path nonExistFile = testFolder / Path(u".non_existent_file_1234"_s);
const auto readResult = Utils::IO::readFile(nonExistFile, 1);