blob: a87c417d7d8f3aba826a37f799997b2681df3e9d (
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
45
|
#include <library/cpp/testing/gtest/gtest.h>
#include <library/cpp/yt/containers/enum_indexed_array.h>
namespace NYT {
namespace {
////////////////////////////////////////////////////////////////////////////////
DEFINE_ENUM(EColor,
((Red) (10))
((Green)(20))
((Blue) (30))
);
TEST(TEnumIndexedArrayTest, Size)
{
TEnumIndexedArray<EColor, int> arr;
EXPECT_EQ(std::ssize(arr), 21);
}
TEST(TEnumIndexedArrayTest, IsValidIndex)
{
TEnumIndexedArray<EColor, int> arr;
EXPECT_TRUE(arr.IsValidIndex(EColor::Red));
EXPECT_TRUE(arr.IsValidIndex(EColor::Green));
EXPECT_TRUE(arr.IsValidIndex(EColor::Blue));
EXPECT_TRUE(arr.IsValidIndex(static_cast<EColor>(11)));
EXPECT_FALSE(arr.IsValidIndex(static_cast<EColor>(9)));
}
TEST(TEnumIndexedArrayTest, Simple)
{
TEnumIndexedArray<EColor, int> arr;
EXPECT_EQ(arr[EColor::Red], 0);
arr[EColor::Red] = 1;
EXPECT_EQ(arr[EColor::Red], 1);
EXPECT_EQ(arr[EColor::Blue], 0);
}
////////////////////////////////////////////////////////////////////////////////
} // namespace
} // namespace NYT
|