11#include < ydb/core/config/tools/protobuf_plugin/ut/protos/config_root_test.pb.h>
2+ #include < ydb/core/config/tools/protobuf_plugin/ut/protos/copy_to_test.pb.h>
23
34#include < library/cpp/testing/unittest/registar.h>
45
@@ -21,4 +22,154 @@ Y_UNIT_TEST_SUITE(ValidationTests) {
2122 UNIT_ASSERT (msg.HasField1 ());
2223 UNIT_ASSERT ((msg.*has1)());
2324 }
25+
26+ Y_UNIT_TEST (CanCopyTo) {
27+ NKikimrConfig::SourceMessage source;
28+ NKikimrConfig::FirstSinkMessage firstSink;
29+ NKikimrConfig::SecondSinkMessage secondSink;
30+
31+ source.CopyToFirstSinkMessage (firstSink);
32+ source.CopyToSecondSinkMessage (secondSink);
33+
34+ UNIT_ASSERT (!source.HasStringField1 ());
35+ UNIT_ASSERT (!source.HasStringField2 ());
36+ UNIT_ASSERT (!source.HasStringField3 ());
37+ UNIT_ASSERT (!source.HasStringField4 ());
38+ UNIT_ASSERT (!source.StringField5Size ());
39+ UNIT_ASSERT (!source.StringField6Size ());
40+ UNIT_ASSERT (!source.StringField7Size ());
41+ UNIT_ASSERT (!source.StringField8Size ());
42+ UNIT_ASSERT (!source.HasComplexMessage1 ());
43+ UNIT_ASSERT (!source.HasComplexMessage2 ());
44+ UNIT_ASSERT (!source.HasComplexMessage3 ());
45+ UNIT_ASSERT (!source.HasComplexMessage4 ());
46+ UNIT_ASSERT (!source.ComplexMessage5Size ());
47+ UNIT_ASSERT (!source.ComplexMessage6Size ());
48+ UNIT_ASSERT (!source.ComplexMessage7Size ());
49+ UNIT_ASSERT (!source.ComplexMessage8Size ());
50+
51+ UNIT_ASSERT (!firstSink.HasStringField2 ());
52+ UNIT_ASSERT (!firstSink.HasStringField4 ());
53+ UNIT_ASSERT (!firstSink.StringField6Size ());
54+ UNIT_ASSERT (!firstSink.StringField8Size ());
55+ UNIT_ASSERT (!firstSink.HasComplexMessage2 ());
56+ UNIT_ASSERT (!firstSink.HasComplexMessage4 ());
57+ UNIT_ASSERT (!firstSink.ComplexMessage6Size ());
58+ UNIT_ASSERT (!firstSink.ComplexMessage8Size ());
59+
60+ UNIT_ASSERT (!secondSink.HasStringField3 ());
61+ UNIT_ASSERT (!secondSink.HasStringField4 ());
62+ UNIT_ASSERT (!secondSink.StringField7Size ());
63+ UNIT_ASSERT (!secondSink.StringField8Size ());
64+ UNIT_ASSERT (!secondSink.HasComplexMessage3 ());
65+ UNIT_ASSERT (!secondSink.HasComplexMessage4 ());
66+ UNIT_ASSERT (!secondSink.ComplexMessage7Size ());
67+ UNIT_ASSERT (!secondSink.ComplexMessage8Size ());
68+
69+ source.SetStringField1 (" string1" );
70+ source.SetStringField2 (" string2" );
71+ source.SetStringField3 (" string3" );
72+ source.SetStringField4 (" string4" );
73+ source.AddStringField5 (" string5-1" );
74+ source.AddStringField5 (" string5-2" );
75+ source.AddStringField6 (" string6-1" );
76+ source.AddStringField6 (" string6-2" );
77+ source.AddStringField6 (" string6-3" );
78+ source.AddStringField7 (" string7-1" );
79+ source.AddStringField7 (" string7-2" );
80+ source.AddStringField7 (" string7-3" );
81+ source.AddStringField7 (" string7-4" );
82+ source.AddStringField8 (" string8-1" );
83+ source.AddStringField8 (" string8-2" );
84+ source.AddStringField8 (" string8-3" );
85+ source.AddStringField8 (" string8-4" );
86+ source.AddStringField8 (" string8-5" );
87+
88+ source.SetIntField (1 );
89+
90+ source.MutableComplexMessage1 ()->SetStringField (" cm1-string" );
91+ source.MutableComplexMessage2 ()->SetStringField (" cm2-string" );
92+ source.MutableComplexMessage3 ()->SetStringField (" cm3-string" );
93+ source.MutableComplexMessage4 ()->SetStringField (" cm4-string" );
94+ source.AddComplexMessage5 ()->SetStringField (" cm5-string-1" );
95+ source.AddComplexMessage5 ()->SetStringField (" cm5-string-2" );
96+ source.AddComplexMessage6 ()->SetStringField (" cm6-string-1" );
97+ source.AddComplexMessage6 ()->SetStringField (" cm6-string-2" );
98+ source.AddComplexMessage6 ()->SetStringField (" cm6-string-3" );
99+ source.AddComplexMessage7 ()->SetStringField (" cm7-string-1" );
100+ source.AddComplexMessage7 ()->SetStringField (" cm7-string-2" );
101+ source.AddComplexMessage7 ()->SetStringField (" cm7-string-3" );
102+ source.AddComplexMessage7 ()->SetStringField (" cm7-string-4" );
103+ source.AddComplexMessage8 ()->SetStringField (" cm8-string-1" );
104+ source.AddComplexMessage8 ()->SetStringField (" cm8-string-2" );
105+ source.AddComplexMessage8 ()->SetStringField (" cm8-string-3" );
106+ source.AddComplexMessage8 ()->SetStringField (" cm8-string-4" );
107+ source.AddComplexMessage8 ()->SetStringField (" cm8-string-5" );
108+
109+ firstSink.SetIntField (2 );
110+ secondSink.SetIntField (3 );
111+
112+ TString expectedSource = source.ShortDebugString ();
113+
114+ source.CopyToFirstSinkMessage (firstSink);
115+
116+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField2 (), source.GetStringField2 ());
117+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField4 (), source.GetStringField4 ());
118+ UNIT_ASSERT_VALUES_EQUAL (firstSink.StringField6Size (), source.StringField6Size ());
119+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField6 (0 ), source.GetStringField6 (0 ));
120+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField6 (1 ), source.GetStringField6 (1 ));
121+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField6 (2 ), source.GetStringField6 (2 ));
122+ UNIT_ASSERT_VALUES_EQUAL (firstSink.StringField8Size (), source.StringField8Size ());
123+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField8 (0 ), source.GetStringField8 (0 ));
124+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField8 (1 ), source.GetStringField8 (1 ));
125+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField8 (2 ), source.GetStringField8 (2 ));
126+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField8 (3 ), source.GetStringField8 (3 ));
127+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetStringField8 (4 ), source.GetStringField8 (4 ));
128+ UNIT_ASSERT_VALUES_EQUAL (firstSink.ComplexMessage6Size (), source.ComplexMessage6Size ());
129+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage6 (0 ).ShortDebugString (), source.GetComplexMessage6 (0 ).ShortDebugString ());
130+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage6 (1 ).ShortDebugString (), source.GetComplexMessage6 (1 ).ShortDebugString ());
131+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage6 (2 ).ShortDebugString (), source.GetComplexMessage6 (2 ).ShortDebugString ());
132+ UNIT_ASSERT_VALUES_EQUAL (firstSink.ComplexMessage8Size (), source.ComplexMessage8Size ());
133+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage8 (0 ).ShortDebugString (), source.GetComplexMessage8 (0 ).ShortDebugString ());
134+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage8 (1 ).ShortDebugString (), source.GetComplexMessage8 (1 ).ShortDebugString ());
135+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage8 (2 ).ShortDebugString (), source.GetComplexMessage8 (2 ).ShortDebugString ());
136+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage8 (3 ).ShortDebugString (), source.GetComplexMessage8 (3 ).ShortDebugString ());
137+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetComplexMessage8 (4 ).ShortDebugString (), source.GetComplexMessage8 (4 ).ShortDebugString ());
138+ UNIT_ASSERT_VALUES_EQUAL (firstSink.GetIntField (), 2 );
139+
140+ UNIT_ASSERT_VALUES_EQUAL (expectedSource, source.ShortDebugString ());
141+
142+ TString expectedFirstSink = firstSink.ShortDebugString ();
143+
144+ source.CopyToSecondSinkMessage (secondSink);
145+
146+ UNIT_ASSERT_VALUES_EQUAL (expectedSource, source.ShortDebugString ());
147+ UNIT_ASSERT_VALUES_EQUAL (expectedFirstSink, firstSink.ShortDebugString ());
148+
149+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField3 (), source.GetStringField3 ());
150+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField4 (), source.GetStringField4 ());
151+ UNIT_ASSERT_VALUES_EQUAL (secondSink.StringField7Size (), source.StringField7Size ());
152+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField7 (0 ), source.GetStringField7 (0 ));
153+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField7 (1 ), source.GetStringField7 (1 ));
154+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField7 (2 ), source.GetStringField7 (2 ));
155+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField7 (3 ), source.GetStringField7 (3 ));
156+ UNIT_ASSERT_VALUES_EQUAL (secondSink.StringField8Size (), source.StringField8Size ());
157+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField8 (0 ), source.GetStringField8 (0 ));
158+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField8 (1 ), source.GetStringField8 (1 ));
159+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField8 (2 ), source.GetStringField8 (2 ));
160+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField8 (3 ), source.GetStringField8 (3 ));
161+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetStringField8 (4 ), source.GetStringField8 (4 ));
162+ UNIT_ASSERT_VALUES_EQUAL (secondSink.ComplexMessage7Size (), source.ComplexMessage7Size ());
163+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage7 (0 ).ShortDebugString (), source.GetComplexMessage7 (0 ).ShortDebugString ());
164+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage7 (1 ).ShortDebugString (), source.GetComplexMessage7 (1 ).ShortDebugString ());
165+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage7 (2 ).ShortDebugString (), source.GetComplexMessage7 (2 ).ShortDebugString ());
166+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage7 (3 ).ShortDebugString (), source.GetComplexMessage7 (3 ).ShortDebugString ());
167+ UNIT_ASSERT_VALUES_EQUAL (secondSink.ComplexMessage8Size (), source.ComplexMessage8Size ());
168+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage8 (0 ).ShortDebugString (), source.GetComplexMessage8 (0 ).ShortDebugString ());
169+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage8 (1 ).ShortDebugString (), source.GetComplexMessage8 (1 ).ShortDebugString ());
170+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage8 (2 ).ShortDebugString (), source.GetComplexMessage8 (2 ).ShortDebugString ());
171+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage8 (3 ).ShortDebugString (), source.GetComplexMessage8 (3 ).ShortDebugString ());
172+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetComplexMessage8 (4 ).ShortDebugString (), source.GetComplexMessage8 (4 ).ShortDebugString ());
173+ UNIT_ASSERT_VALUES_EQUAL (secondSink.GetIntField (), 3 );
174+ }
24175}
0 commit comments