Check return value of 'virtual bool QFile::open(QIODeviceBase::OpenMode)'
Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
This commit is contained in:
@@ -48,7 +48,10 @@ class LibraryTest : public QObject {
|
||||
LibraryPtr readMojangJson(const QString path)
|
||||
{
|
||||
QFile jsonFile(path);
|
||||
jsonFile.open(QIODevice::ReadOnly);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "Failed to open file '" << jsonFile.fileName() << "' for reading!";
|
||||
return LibraryPtr();
|
||||
}
|
||||
auto data = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
ProblemContainer problems;
|
||||
|
||||
@@ -9,7 +9,10 @@ class MojangVersionFormatTest : public QObject {
|
||||
static QJsonDocument readJson(const QString path)
|
||||
{
|
||||
QFile jsonFile(path);
|
||||
jsonFile.open(QIODevice::ReadOnly);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "Failed to open file '" << jsonFile.fileName() << "' for reading!";
|
||||
return QJsonDocument();
|
||||
}
|
||||
auto data = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
return QJsonDocument::fromJson(data);
|
||||
@@ -17,7 +20,10 @@ class MojangVersionFormatTest : public QObject {
|
||||
static void writeJson(const char* file, QJsonDocument doc)
|
||||
{
|
||||
QFile jsonFile(file);
|
||||
jsonFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
if (!jsonFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qCritical() << "Failed to open file '" << jsonFile.fileName() << "' for writing!";
|
||||
return;
|
||||
}
|
||||
auto data = doc.toJson(QJsonDocument::Indented);
|
||||
qDebug() << QString::fromUtf8(data);
|
||||
jsonFile.write(data);
|
||||
|
||||
@@ -106,7 +106,10 @@ class VersionTest : public QObject {
|
||||
|
||||
QFile vector_file{ test_vector_dir.absoluteFilePath("test_vectors.txt") };
|
||||
|
||||
vector_file.open(QFile::OpenModeFlag::ReadOnly);
|
||||
if (!vector_file.open(QFile::OpenModeFlag::ReadOnly)) {
|
||||
qCritical() << "Failed to open file '" << vector_file.fileName() << "' for reading!";
|
||||
return;
|
||||
}
|
||||
|
||||
int test_number = 0;
|
||||
const QString test_name_template{ "FlexVer test #%1 (%2)" };
|
||||
|
||||
Reference in New Issue
Block a user