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
47
48
49
|
#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/unittest/registar.h>
#include <util/generic/serialized_enum.h>
using namespace NYT;
Y_UNIT_TEST_SUITE(Serialization)
{
Y_UNIT_TEST(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();
UNIT_ASSERT(schemaNode.IsList());
UNIT_ASSERT_VALUES_EQUAL(schemaNode.Size(), 3);
UNIT_ASSERT_VALUES_EQUAL(schemaNode[0]["name"], "a");
UNIT_ASSERT_VALUES_EQUAL(schemaNode[0]["type"], "string");
UNIT_ASSERT_VALUES_EQUAL(schemaNode[0]["required"], false);
UNIT_ASSERT_VALUES_EQUAL(schemaNode[0]["sort_order"], "ascending");
UNIT_ASSERT_VALUES_EQUAL(schemaNode[1]["name"], "b");
UNIT_ASSERT_VALUES_EQUAL(schemaNode[1]["type"], "uint64");
UNIT_ASSERT_VALUES_EQUAL(schemaNode[1]["required"], false);
UNIT_ASSERT_VALUES_EQUAL(schemaNode[2]["name"], "c");
UNIT_ASSERT_VALUES_EQUAL(schemaNode[2]["type"], "int64");
UNIT_ASSERT_VALUES_EQUAL(schemaNode[2]["required"], true);
}
Y_UNIT_TEST(ValueTypeSerialization)
{
for (const auto value : GetEnumAllValues<EValueType>()) {
TNode serialized = NYT::NDetail::ToString(value);
EValueType deserialized;
Deserialize(deserialized, serialized);
UNIT_ASSERT_VALUES_EQUAL(value, deserialized);
}
}
}
|