1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/test/webfuse/tests/adapter/test_mountpoint.cc

47 lines
1.0 KiB
C++
Raw Normal View History

2020-02-15 14:11:35 +00:00
#include <gtest/gtest.h>
#include <gmock/gmock.h>
2020-02-15 14:11:35 +00:00
#include "webfuse/adapter/mountpoint.h"
namespace
{
2020-02-16 03:02:23 +00:00
class MockUserDataDisposer
{
public:
2020-02-16 03:02:23 +00:00
MOCK_METHOD1(dispose, void(void * mountpoint));
};
2020-02-16 03:02:23 +00:00
MockUserDataDisposer * global_disposer = nullptr;
2020-02-16 03:02:23 +00:00
void ondispose(void * user_data)
{
2020-02-16 03:02:23 +00:00
global_disposer->dispose(user_data);
}
}
2020-02-15 14:11:35 +00:00
TEST(mountpoint, get_path)
{
wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path");
ASSERT_NE(nullptr, mountpoint);
2020-02-15 14:11:35 +00:00
ASSERT_STREQ("/some/path", wf_mountpoint_get_path(mountpoint));
wf_mountpoint_dispose(mountpoint);
}
TEST(mountpoint, ondispose)
{
2020-02-16 03:02:23 +00:00
MockUserDataDisposer disposer;
global_disposer = &disposer;
wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path");
ASSERT_NE(nullptr, mountpoint);
2020-02-16 03:02:23 +00:00
int value = 42;
void * user_data = reinterpret_cast<void*>(&value);
wf_mountpoint_set_userdata(mountpoint, user_data, ondispose);
EXPECT_CALL(disposer, dispose(user_data)).Times(1);
wf_mountpoint_dispose(mountpoint);
}