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

Method TestIntrPtr

util/generic/ptr_ut.cpp:344–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344void TPointerTest::TestIntrPtr() {
345 {
346 TIntrusivePtr<TOp> p, p2;
347 TOp3 op3;
348 {
349 TVector<TIntrusivePtr<TOp>> f1;
350 {
351 TVector<TIntrusivePtr<TOp>> f2;
352 f2.push_back(new TOp);
353 p = new TOp;
354 f2.push_back(p);
355 Attach(&op3, &f2[1]);
356 f1 = f2;
357 UNIT_ASSERT_VALUES_EQUAL(f1[0]->RefCount(), 2);
358 UNIT_ASSERT_VALUES_EQUAL(f1[1]->RefCount(), 3);
359 UNIT_ASSERT_EQUAL(f1[1].Get(), op3.Op2.Get());
360 UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 3);
361 UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 2);
362 UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 4);
363 }
364 p2 = p;
365 }
366 UNIT_ASSERT_VALUES_EQUAL(op3.Op2->RefCount(), 1);
367 UNIT_ASSERT_VALUES_EQUAL(op3.Op2->Op->RefCount(), 3);
368 UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 3);
369 }
370 UNIT_ASSERT_VALUES_EQUAL(TOp::Cnt, 0);
371}
372
373namespace NTestIntrusiveConvertion {
374 struct TA: public TSimpleRefCount<TA> {

Callers

nothing calls this directly

Calls 4

AttachFunction · 0.85
push_backMethod · 0.45
RefCountMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected