mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
format; use explicit for construct with default values; rewrite GetImagePath usage
This commit is contained in:
parent
8ceb08dbf4
commit
bb871df80f
|
@ -24,8 +24,8 @@ namespace {
|
||||||
|
|
||||||
class TiffSapiSandbox : public TiffSandbox {
|
class TiffSapiSandbox : public TiffSandbox {
|
||||||
public:
|
public:
|
||||||
TiffSapiSandbox(std::optional<std::string> file = std::nullopt,
|
explicit TiffSapiSandbox(std::optional<std::string> file = std::nullopt,
|
||||||
std::optional<std::string> dir = std::nullopt)
|
std::optional<std::string> dir = std::nullopt)
|
||||||
: file_(std::move(file)), dir_(std::move(dir)) {}
|
: file_(std::move(file)), dir_(std::move(dir)) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "../sandboxed.h" // NOLINT(build/include)
|
#include "../sandboxed.h" // NOLINT(build/include)
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "helper.h" // NOLINT(build/include)
|
#include "helper.h" // NOLINT(build/include)
|
||||||
|
@ -21,8 +23,6 @@
|
||||||
#include "sandboxed_api/util/status_matchers.h"
|
#include "sandboxed_api/util/status_matchers.h"
|
||||||
#include "tiffio.h" // NOLINT(build/include)
|
#include "tiffio.h" // NOLINT(build/include)
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ::sapi::IsOk;
|
using ::sapi::IsOk;
|
||||||
|
@ -39,15 +39,14 @@ constexpr uint16_t kSamplePerPixel = 1;
|
||||||
using NongeneratedArgs = std::tuple<std::string_view, int>;
|
using NongeneratedArgs = std::tuple<std::string_view, int>;
|
||||||
using TestArgsType = std::tuple<NongeneratedArgs, int>;
|
using TestArgsType = std::tuple<NongeneratedArgs, int>;
|
||||||
|
|
||||||
constexpr std::array<NongeneratedArgs, 4> kTestData = {{
|
constexpr std::array<NongeneratedArgs, 4> kTestData = {
|
||||||
{"w", 1}, {"w", 10}, {"w8", 1}, {"wD", 1}
|
{{"w", 1}, {"w", 10}, {"w8", 1}, {"wD", 1}}};
|
||||||
}};
|
|
||||||
|
|
||||||
struct TestParams {
|
struct TestParams {
|
||||||
TestParams(const TestArgsType& in)
|
TestParams(const TestArgsType& in)
|
||||||
: mode(std::get<0>(std::get<0>(in))), tiled(std::get<1>(in)),
|
: mode(std::get<0>(std::get<0>(in))),
|
||||||
height(std::get<1>(std::get<0>(in))) {
|
tiled(std::get<1>(in)),
|
||||||
}
|
height(std::get<1>(std::get<0>(in))) {}
|
||||||
|
|
||||||
std::string mode;
|
std::string mode;
|
||||||
int tiled;
|
int tiled;
|
||||||
|
@ -141,7 +140,8 @@ TEST_P(TestDeferStrileWriting, TestWriting) {
|
||||||
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteCheck fatal error";
|
ASSERT_THAT(status_or_int, IsOk()) << "TIFFWriteCheck fatal error";
|
||||||
EXPECT_THAT(status_or_int.value(), IsTrue())
|
EXPECT_THAT(status_or_int.value(), IsTrue())
|
||||||
<< "TIFFWriteCheck return unexpected value "
|
<< "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);
|
status_or_int = api.TIFFWriteDirectory(&tif);
|
||||||
ASSERT_THAT(status_or_int, IsOk())
|
ASSERT_THAT(status_or_int, IsOk())
|
||||||
|
@ -335,10 +335,8 @@ TEST_P(TestDeferStrileWriting, TestWriting) {
|
||||||
unlink(srcfile.c_str());
|
unlink(srcfile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(SandboxTest, TestDeferStrileWriting,
|
||||||
SandboxTest, TestDeferStrileWriting,
|
testing::Combine(testing::ValuesIn(kTestData),
|
||||||
testing::Combine(
|
testing::Values(0, 1)));
|
||||||
testing::ValuesIn(kTestData),
|
|
||||||
testing::Values(0, 1)));
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -32,9 +32,6 @@ std::string GetImagesFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetFilePath(const std::string& filename) {
|
std::string GetFilePath(const std::string& filename) {
|
||||||
static std::string* images_folder_path = nullptr;
|
std::string images_folder_path = GetImagesFolder();
|
||||||
if (!images_folder_path) {
|
return sandbox2::file::JoinPath(images_folder_path, filename);
|
||||||
images_folder_path = new std::string(GetImagesFolder());
|
|
||||||
}
|
|
||||||
return sandbox2::file::JoinPath(*images_folder_path, filename);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user