userver: /data/code/userver/libraries/proto-structs/codegen-tests/src/not_recommended_field_names/basic_test.cpp Source File
Loading...
Searching...
No Matches
basic_test.cpp
1#include <gtest/gtest.h>
2
3#include <not_recommended_field_names/basic.pb.h>
4#include <not_recommended_field_names/basic.structs.usrv.pb.hpp>
5
6#include <userver/proto-structs/convert.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10TEST(NotRecommendedFieldNameBasic, Basic) {
11 using Struct = not_recommended_field_names::structs::Basic;
12 Struct s{};
13
14 s.protected_ = 0;
15 s.final_ = 1;
16 s.void__ = 2;
17 s.float_ = 3;
18 s.typeid_ = 4;
19 s.new_ = 5;
20 s.double_ = 6;
21
22 Struct::ProtobufMessage vanilla{};
23 proto_structs::StructToMessage(std::move(s), vanilla);
24
25 ASSERT_EQ(vanilla.protected_(), 0);
26 ASSERT_EQ(vanilla.final(), 1);
27 ASSERT_EQ(vanilla.void__(), 2);
28 ASSERT_EQ(vanilla.float_(), 3);
29 ASSERT_EQ(vanilla.typeid_(), 4);
30 ASSERT_EQ(vanilla.new_(), 5);
31 ASSERT_EQ(vanilla.double_(), 6);
32 // Not generated by a plagin.
33 ASSERT_EQ(vanilla.minor(), 0);
34 ASSERT_EQ(vanilla.major(), 0);
35}
36
37TEST(NotRecommendedFieldNameBasic, Upper) {
38 using Struct = not_recommended_field_names::structs::Upper;
39 Struct s{};
40 s.XYandexUid = 1;
41 s.Float = 2;
42 s.New = 3;
43
44 Struct::ProtobufMessage vanilla{};
45 proto_structs::StructToMessage(std::move(s), vanilla);
46 ASSERT_EQ(vanilla.xyandexuid(), 1);
47 ASSERT_EQ(vanilla.float_(), 2);
48 ASSERT_EQ(vanilla.new_(), 3);
49}
50
51USERVER_NAMESPACE_END