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

Function SmokingTest

library/cpp/containers/flat_hash/ut/containers_ut.cpp:155–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153
154 template <class Container, class... Args>
155 void SmokingTest(typename Container::size_type size, Args&&... args) {
156 using size_type = typename Container::size_type;
157 using value_type = typename Container::value_type;
158
159 Container cont(size, std::forward<Args>(args)...);
160 UNIT_ASSERT_EQUAL(cont.Size(), size);
161 UNIT_ASSERT_EQUAL(cont.Taken(), 0);
162
163 for (size_type i = 0; i < cont.Size(); ++i) {
164 UNIT_ASSERT(cont.IsEmpty(i));
165 UNIT_ASSERT(!cont.IsTaken(i));
166 }
167
168 // Filling the container till half
169 TVector<size_type> toInsert(cont.Size());
170 Iota(toInsert.begin(), toInsert.end(), 0);
171 Shuffle(toInsert.begin(), toInsert.end());
172 toInsert.resize(toInsert.size() / 2);
173 for (auto i : toInsert) {
174 UNIT_ASSERT(cont.IsEmpty(i));
175 UNIT_ASSERT(!cont.IsTaken(i));
176 value_type value(RandomNumber<size_type>(cont.Size()));
177 cont.InitNode(i, value);
178 UNIT_ASSERT(!cont.IsEmpty(i));
179 UNIT_ASSERT(cont.IsTaken(i));
180 UNIT_ASSERT_EQUAL(cont.Node(i), value);
181 }
182 UNIT_ASSERT_EQUAL(cont.Taken(), toInsert.size());
183
184 // Copy construction test
185 auto cont2 = cont;
186 CheckContainersEqual(cont, cont2);
187
188 // Copy assignment test
189 cont2 = cont2.Clone(0);
190 UNIT_ASSERT_EQUAL(cont2.Size(), 0);
191 UNIT_ASSERT_EQUAL(cont2.Taken(), 0);
192
193 // Copy assignment test
194 cont2 = cont;
195 CheckContainersEqual(cont, cont2);
196
197 // Move construction test
198 auto cont3 = std::move(cont2);
199 UNIT_ASSERT_EQUAL(cont2.Size(), 0);
200 CheckContainersEqual(cont, cont3);
201
202 // Move assignment test
203 cont2 = std::move(cont3);
204 UNIT_ASSERT_EQUAL(cont3.Size(), 0);
205 CheckContainersEqual(cont, cont2);
206 }
207}
208
209Y_UNIT_TEST_SUITE(TFlatContainerTest) {

Callers

nothing calls this directly

Calls 15

IotaFunction · 0.85
CheckContainersEqualFunction · 0.85
ShuffleFunction · 0.50
moveFunction · 0.50
SizeMethod · 0.45
TakenMethod · 0.45
IsEmptyMethod · 0.45
IsTakenMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected