1
0
mirror of https://github.com/falk-werner/webfuse synced 2026-03-02 03:40:24 +00:00

sepated unit and integration tests

This commit is contained in:
Falk Werner
2023-01-01 13:01:35 +01:00
parent dcb590bd50
commit 0e0bb74872
19 changed files with 34 additions and 19 deletions

View File

@@ -0,0 +1,26 @@
#include "webfuse/filesystem/accessmode.hpp"
#include <gtest/gtest.h>
using webfuse::access_mode;
TEST(accessmode, f_ok)
{
ASSERT_EQ(0, access_mode::f_ok);
ASSERT_EQ(F_OK, access_mode::f_ok);
}
class accessmode_test: public testing::TestWithParam<int> { };
TEST_P(accessmode_test, conversion)
{
int const expected = GetParam();
auto mode = access_mode::from_int(expected);
ASSERT_EQ(expected, mode.to_int());
}
INSTANTIATE_TEST_CASE_P(accesmode_values, accessmode_test,
testing::Values(
F_OK, R_OK, W_OK, X_OK,
R_OK | W_OK, R_OK | X_OK, W_OK | X_OK,
R_OK | W_OK | X_OK)
);

View File

@@ -0,0 +1,25 @@
#include "webfuse/filesystem/filemode.hpp"
#include <gtest/gtest.h>
using webfuse::filemode;
class filemode_test: public testing::TestWithParam<mode_t> { };
TEST_P(filemode_test, conversion)
{
mode_t const expected = GetParam();
auto value = filemode::from_mode(expected);
ASSERT_EQ(expected, value.to_mode());
}
INSTANTIATE_TEST_CASE_P(filemode_value, filemode_test,
testing::Values(
S_IROTH, S_IWOTH, S_IXOTH,
S_IRGRP, S_IWGRP, S_IXGRP,
S_IRUSR, S_IWUSR, S_IXUSR,
S_ISUID, S_ISGID, S_ISVTX,
S_IFREG, S_IFCHR, S_IFBLK, S_IFDIR, S_IFIFO, S_IFLNK, S_IFSOCK,
S_IFREG | 0644,
S_IFDIR | 0755
)
);

View File

@@ -0,0 +1,24 @@
#include "webfuse/filesystem/openflags.hpp"
#include <gtest/gtest.h>
#include <fcntl.h>
using webfuse::openflags;
class openflags_test: public testing::TestWithParam<int> { };
TEST_P(openflags_test, conversion)
{
int const expected = GetParam();
auto flags = openflags::from_int(expected);
ASSERT_EQ(expected, flags.to_int());
}
INSTANTIATE_TEST_CASE_P(openflags_values, openflags_test,
testing::Values<>(
O_RDONLY, O_WRONLY, O_RDWR, O_CLOEXEC, O_CREAT,
O_DIRECT, O_DIRECTORY, O_EXCL, O_NOCTTY, O_NOFOLLOW,
O_TRUNC, O_ASYNC, O_LARGEFILE, O_NOATIME, O_NONBLOCK,
O_NDELAY, O_SYNC,
O_WRONLY | O_CREAT | O_TRUNC
)
);

View File

@@ -0,0 +1,28 @@
#include "webfuse/filesystem/status.hpp"
#include <gtest/gtest.h>
#include <errno.h>
using webfuse::status;
class status_test: public testing::TestWithParam<int> { };
TEST_P(status_test, conversion)
{
int const expected = GetParam();
auto status = status::from_fusestatus(expected);
ASSERT_EQ(expected, status.to_fusestatus());
}
INSTANTIATE_TEST_CASE_P(status_values, status_test,
testing::Values(
0, 1, 2, 3, 42,
-E2BIG, -EACCES, -EBADF, -EBUSY, -EDESTADDRREQ,
-EDQUOT, -EEXIST, -EFAULT, -EFBIG, -EINTR,
-EINVAL, -EIO, -EISDIR, -ELOOP, -EMFILE,
-ENAMETOOLONG, -ENFILE, -ENODATA, -ENODEV,
-ENOENT, -ENOMEM, -ENOSPC, -ENOSYS, -ENOTDIR,
-ENOTEMPTY, -ENOTSUP, -ENXIO, -EOVERFLOW, -EPERM,
-EPIPE, -ERANGE, -EROFS, -EXDEV, -EWOULDBLOCK,
-EAGAIN, -12345
)
);