Merge pull request #2 from alexelex/alexelex-libtiff

pr rewiew fixes
This commit is contained in:
Latysheva Alexandra 2020-10-20 02:57:12 +06:00 committed by GitHub
commit 58f19a7d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 20 deletions

View File

@ -171,8 +171,8 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
TiffSapiSandbox sandbox(srcfile);
bool pixel_status = true;
bool cluster_status = true;
bool pixel_status_ok = true;
bool cluster_status_ok = true;
// initialize sapi vars after constructing TiffSapiSandbox
sapi::v::UShort h;
sapi::v::UShort v;
@ -226,10 +226,10 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
if (status = CheckCluster(id, buffer_, data); !status.ok()) {
LOG(ERROR) << "CheckCluster failed:\n" << status.ToString();
}
cluster_status &= status.ok();
cluster_status_ok &= status.ok();
}
if (!cluster_status) {
if (!cluster_status_ok) {
return absl::InternalError("One or more clusters failed the check");
}
@ -262,7 +262,7 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
if (status = CheckRgbPixel(id, data, buffer2_); !status.ok()) {
LOG(ERROR) << "CheckRgbPixel failed:\n" << status.ToString();
}
pixel_status &= status.ok();
pixel_status_ok &= status.ok();
}
SAPI_RETURN_IF_ERROR(api.TIFFClose(&tif));
@ -290,12 +290,12 @@ absl::Status LibTIFFMain(const std::string& srcfile) {
if (status = CheckRgbaPixel(id, data, rgba_buffer_); !status.ok()) {
LOG(ERROR) << "CheckRgbaPixel failed:\n" << status.ToString();
}
pixel_status &= status.ok();
pixel_status_ok &= status.ok();
}
SAPI_RETURN_IF_ERROR(api.TIFFClose(&tif2));
if (!pixel_status) {
if (!pixel_status_ok) {
return absl::InternalError("wrong encoding");
}

View File

@ -101,7 +101,7 @@ TEST(SandboxTest, LongTag) {
EXPECT_THAT(status_or_int.value(), IsTrue())
<< "Can't set PhotometricInterpretation tag";
for (auto& tag : kLongTags) {
for (const auto& tag : kLongTags) {
status_or_int = api.TIFFSetFieldU1(&tif, tag.tag, tag.value);
ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort1 fatal error";
EXPECT_THAT(status_or_int.value(), IsTrue()) << "Can't set tag " << tag.tag;
@ -125,7 +125,7 @@ TEST(SandboxTest, LongTag) {
CheckLongField(api, tif2, TIFFTAG_IMAGELENGTH, kLength);
CheckLongField(api, tif2, TIFFTAG_ROWSPERSTRIP, kRowsPerStrip);
for (auto& tag : kLongTags) {
for (const auto& tag : kLongTags) {
CheckLongField(api, tif2, tag.tag, tag.value);
}

View File

@ -138,8 +138,8 @@ bool CheckRgbaPixel(uint32_t pixel, const ChannelLimits& limits,
TEST(SandboxTest, RawDecode) {
tsize_t sz;
bool pixel_status = false;
bool cluster_status = false;
bool pixel_status_ok = false;
bool cluster_status_ok = false;
std::string srcfile = GetFilePath("quad-tile.jpg.tiff");
TiffSapiSandbox sandbox(srcfile);
@ -187,9 +187,9 @@ TEST(SandboxTest, RawDecode) {
<< (int)status_or_long.value() << " instead of " << (int)sz << ")";
for (const auto& [id, data] : kClusters) {
cluster_status |= CheckCluster(id, buffer_, data);
cluster_status_ok |= CheckCluster(id, buffer_, data);
}
ASSERT_FALSE(cluster_status) << "Clusters did not match expected results";
ASSERT_FALSE(cluster_status_ok) << "Clusters did not match expected results";
status_or_int =
api.TIFFSetFieldU1(&tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
@ -213,7 +213,7 @@ TEST(SandboxTest, RawDecode) {
<< status_or_long.value() << " instead of " << sz;
for (const auto& [id, data] : kLimits) {
pixel_status |= CheckRgbPixel(id, data, buffer2_);
pixel_status_ok |= CheckRgbPixel(id, data, buffer2_);
}
ASSERT_THAT(api.TIFFClose(&tif), IsOk()) << "TIFFClose fatal error";
@ -234,11 +234,11 @@ TEST(SandboxTest, RawDecode) {
<< "TIFFReadRGBATile() returned failure code";
for (const auto& [id, data] : kLimits) {
pixel_status |= CheckRgbaPixel(id, data, rgba_buffer_);
pixel_status_ok |= CheckRgbaPixel(id, data, rgba_buffer_);
}
EXPECT_THAT(api.TIFFClose(&tif2), IsOk()) << "TIFFClose fatal error";
EXPECT_THAT(pixel_status, IsFalse()) << "wrong encoding";
EXPECT_THAT(pixel_status_ok, IsFalse()) << "wrong encoding";
}
} // namespace

View File

@ -123,13 +123,13 @@ TEST(SandboxTest, ShortTag) {
EXPECT_THAT(status_or_int.value(), IsTrue())
<< "Can't set PhotometricInterpretation tag";
for (auto& tag : kShortSingleTags) {
for (const auto& tag : kShortSingleTags) {
status_or_int = api.TIFFSetFieldUShort1(&tif, tag.tag, tag.value);
ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort1 fatal error";
EXPECT_THAT(status_or_int.value(), IsTrue()) << "Can't set tag " << tag.tag;
}
for (auto& tag : kShortPairedTags) {
for (const auto& tag : kShortPairedTags) {
status_or_int =
api.TIFFSetFieldUShort2(&tif, tag.tag, tag.values[0], tag.values[1]);
ASSERT_THAT(status_or_int, IsOk()) << "TIFFSetFieldUShort2 fatal error";
@ -158,11 +158,11 @@ TEST(SandboxTest, ShortTag) {
CheckLongField(api, tif2, TIFFTAG_ROWSPERSTRIP, kRowsPerStrip);
CheckShortField(api, tif2, TIFFTAG_PLANARCONFIG, kPlanarConfig);
for (auto& tag : kShortSingleTags) {
for (const auto& tag : kShortSingleTags) {
CheckShortField(api, tif2, tag.tag, tag.value);
}
for (auto& tag : kShortPairedTags) {
for (const auto& tag : kShortPairedTags) {
CheckShortPairedField(api, tif2, tag.tag, tag.values);
}