aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/unittests/shared_range_ut.cpp
blob: 7b86a1eb15d7a0ae90e214bb40cb00aaf0186b20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <library/cpp/testing/gtest/gtest.h>

#include <library/cpp/yt/memory/new.h>
#include <library/cpp/yt/memory/shared_range.h>

namespace NYT {
namespace {

////////////////////////////////////////////////////////////////////////////////

DECLARE_REFCOUNTED_STRUCT(THolder);

struct THolder
    : public TRefCounted
{
    int Value;

    THolder(int value)
        : Value(value)
    { }
};

DEFINE_REFCOUNTED_TYPE(THolder);

////////////////////////////////////////////////////////////////////////////////

TEST(TSharedRange, Move)
{
    auto holder = New<THolder>(0);
    int* raw = &holder->Value;

    auto sharedRange = MakeSharedRange<int>({raw, 1}, std::move(holder));

    {
        auto sharedRangeMovedTo = std::move(sharedRange);
    }

    EXPECT_TRUE(sharedRange.ToVector().empty());
}

////////////////////////////////////////////////////////////////////////////////

} // namespace
} // namespace NYT