MCPcopy Create free account
hub / github.com/catboost/catboost / TestStreams

Function TestStreams

library/cpp/blockcodecs/codecs_ut.cpp:146–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144 }
145
146 void TestStreams(size_t n, size_t m) {
147 TVector<TString> datas;
148 TString res;
149
150 for (size_t i = 0; i < 256; ++i) {
151 datas.push_back(TString(i, (char)(i % 128)));
152 }
153
154 for (size_t i = 0; i < datas.size(); ++i) {
155 res += datas[i];
156 }
157
158 TCodecList lst = ListAllCodecs();
159
160 for (size_t i = 0; i < lst.size(); ++i) {
161 TStringStream ss;
162
163 const ICodec* c = Codec(lst[i]);
164 const auto h = MultiHash(c->Name(), i, 2);
165
166 if (h % n == m) {
167 } else {
168 continue;
169 }
170
171 {
172 TCodedOutput out(&ss, c, 1234);
173
174 for (size_t j = 0; j < datas.size(); ++j) {
175 out << datas[j];
176 }
177
178 out.Finish();
179 }
180
181 const TString resNew = TDecodedInput(&ss).ReadAll();
182
183 try {
184 UNIT_ASSERT_EQUAL(resNew, res);
185 } catch (...) {
186 Cerr << c->Name() << Endl;
187
188 throw;
189 }
190 }
191 }
192
193 Y_UNIT_TEST(TestStreams0) {
194 TestStreams(20, 0);

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 7

MultiHashFunction · 0.85
TDecodedInputClass · 0.85
ReadAllMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
NameMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected