From bb871df80ffeaf66a112e12f33570e426826893b Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Wed, 28 Oct 2020 12:54:06 +0000 Subject: [PATCH] format; use explicit for construct with default values; rewrite GetImagePath usage --- oss-internship-2020/libtiff/sandboxed.h | 4 +-- .../libtiff/test/defer_strile_writing.cc | 26 +++++++++---------- oss-internship-2020/libtiff/test/helper.cc | 7 ++--- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/oss-internship-2020/libtiff/sandboxed.h b/oss-internship-2020/libtiff/sandboxed.h index 031c633..4af50d4 100644 --- a/oss-internship-2020/libtiff/sandboxed.h +++ b/oss-internship-2020/libtiff/sandboxed.h @@ -24,8 +24,8 @@ namespace { class TiffSapiSandbox : public TiffSandbox { public: - TiffSapiSandbox(std::optional file = std::nullopt, - std::optional dir = std::nullopt) + explicit TiffSapiSandbox(std::optional file = std::nullopt, + std::optional dir = std::nullopt) : file_(std::move(file)), dir_(std::move(dir)) {} private: diff --git a/oss-internship-2020/libtiff/test/defer_strile_writing.cc b/oss-internship-2020/libtiff/test/defer_strile_writing.cc index cc477a5..bc43626 100644 --- a/oss-internship-2020/libtiff/test/defer_strile_writing.cc +++ b/oss-internship-2020/libtiff/test/defer_strile_writing.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "../sandboxed.h" // NOLINT(build/include) #include "gtest/gtest.h" #include "helper.h" // NOLINT(build/include) @@ -21,8 +23,6 @@ #include "sandboxed_api/util/status_matchers.h" #include "tiffio.h" // NOLINT(build/include) -#include - namespace { using ::sapi::IsOk; @@ -39,15 +39,14 @@ constexpr uint16_t kSamplePerPixel = 1; using NongeneratedArgs = std::tuple; using TestArgsType = std::tuple; -constexpr std::array kTestData = {{ - {"w", 1}, {"w", 10}, {"w8", 1}, {"wD", 1} -}}; +constexpr std::array kTestData = { + {{"w", 1}, {"w", 10}, {"w8", 1}, {"wD", 1}}}; struct TestParams { TestParams(const TestArgsType& in) - : mode(std::get<0>(std::get<0>(in))), tiled(std::get<1>(in)), - height(std::get<1>(std::get<0>(in))) { - } + : mode(std::get<0>(std::get<0>(in))), + tiled(std::get<1>(in)), + height(std::get<1>(std::get<0>(in))) {} std::string mode; int tiled; @@ -141,7 +140,8 @@ TEST_P(TestDeferStrileWriting, TestWriting) { ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteCheck fatal error"; EXPECT_THAT(status_or_int.value(), IsTrue()) << "TIFFWriteCheck return unexpected value " - << "void test(" << args.mode << ", " << args.tiled << ", " << args.height << ")"; + << "void test(" << args.mode << ", " << args.tiled << ", " << args.height + << ")"; status_or_int = api.TIFFWriteDirectory(&tif); ASSERT_THAT(status_or_int, IsOk()) @@ -335,10 +335,8 @@ TEST_P(TestDeferStrileWriting, TestWriting) { unlink(srcfile.c_str()); } -INSTANTIATE_TEST_SUITE_P( - SandboxTest, TestDeferStrileWriting, - testing::Combine( - testing::ValuesIn(kTestData), - testing::Values(0, 1))); +INSTANTIATE_TEST_SUITE_P(SandboxTest, TestDeferStrileWriting, + testing::Combine(testing::ValuesIn(kTestData), + testing::Values(0, 1))); } // namespace diff --git a/oss-internship-2020/libtiff/test/helper.cc b/oss-internship-2020/libtiff/test/helper.cc index aec8178..869cfa2 100644 --- a/oss-internship-2020/libtiff/test/helper.cc +++ b/oss-internship-2020/libtiff/test/helper.cc @@ -32,9 +32,6 @@ std::string GetImagesFolder() { } std::string GetFilePath(const std::string& filename) { - static std::string* images_folder_path = nullptr; - if (!images_folder_path) { - images_folder_path = new std::string(GetImagesFolder()); - } - return sandbox2::file::JoinPath(*images_folder_path, filename); + std::string images_folder_path = GetImagesFolder(); + return sandbox2::file::JoinPath(images_folder_path, filename); }