format; use explicit for construct with default values; rewrite GetImagePath usage

This commit is contained in:
Alexandra Latysheva 2020-10-28 12:54:06 +00:00
parent 8ceb08dbf4
commit bb871df80f
3 changed files with 16 additions and 21 deletions

View File

@ -24,8 +24,8 @@ namespace {
class TiffSapiSandbox : public TiffSandbox {
public:
TiffSapiSandbox(std::optional<std::string> file = std::nullopt,
std::optional<std::string> dir = std::nullopt)
explicit TiffSapiSandbox(std::optional<std::string> file = std::nullopt,
std::optional<std::string> dir = std::nullopt)
: file_(std::move(file)), dir_(std::move(dir)) {}
private:

View File

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <array>
#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 <array>
namespace {
using ::sapi::IsOk;
@ -39,15 +39,14 @@ constexpr uint16_t kSamplePerPixel = 1;
using NongeneratedArgs = std::tuple<std::string_view, int>;
using TestArgsType = std::tuple<NongeneratedArgs, int>;
constexpr std::array<NongeneratedArgs, 4> kTestData = {{
{"w", 1}, {"w", 10}, {"w8", 1}, {"wD", 1}
}};
constexpr std::array<NongeneratedArgs, 4> 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

View File

@ -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);
}