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
46
|
#include <yt/cpp/mapreduce/interface/serialize.h>
#include <yt/cpp/mapreduce/interface/common.h>
#include <library/cpp/yson/node/node_builder.h>
#include <library/cpp/testing/gtest/gtest.h>
#include <util/generic/serialized_enum.h>
using namespace NYT;
TEST(TSerializationTest, TableSchema)
{
auto schema = TTableSchema()
.AddColumn(TColumnSchema().Name("a").Type(EValueType::VT_STRING).SortOrder(SO_ASCENDING))
.AddColumn(TColumnSchema().Name("b").Type(EValueType::VT_UINT64))
.AddColumn(TColumnSchema().Name("c").Type(EValueType::VT_INT64, true));
auto schemaNode = schema.ToNode();
EXPECT_TRUE(schemaNode.IsList());
EXPECT_EQ(schemaNode.Size(), 3u);
EXPECT_EQ(schemaNode[0]["name"], "a");
EXPECT_EQ(schemaNode[0]["type"], "string");
EXPECT_EQ(schemaNode[0]["required"], false);
EXPECT_EQ(schemaNode[0]["sort_order"], "ascending");
EXPECT_EQ(schemaNode[1]["name"], "b");
EXPECT_EQ(schemaNode[1]["type"], "uint64");
EXPECT_EQ(schemaNode[1]["required"], false);
EXPECT_EQ(schemaNode[2]["name"], "c");
EXPECT_EQ(schemaNode[2]["type"], "int64");
EXPECT_EQ(schemaNode[2]["required"], true);
}
TEST(TSerializationTest, ValueTypeSerialization)
{
for (const auto value : GetEnumAllValues<EValueType>()) {
TNode serialized = NYT::NDetail::ToString(value);
EValueType deserialized;
Deserialize(deserialized, serialized);
EXPECT_EQ(value, deserialized);
}
}
|