MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / testClassType

Method testClassType

Tests/Libraries/Containers/VectorTest.cpp:339–671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337 }
338}
339void SC::VectorTest::testClassType()
340{
341 using namespace SC;
342 VectorTestReport& vecReport = VectorTestReport::get();
343 vecReport.reset();
344 if (test_section("class_resize"))
345 {
346 StringView myString("MyData");
347 VectorTestClass testClass(myString.bytesWithoutTerminator());
348 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::CONSTRUCTOR);
349 SC_TEST_EXPECT(myString == testClass.toString());
350 SC::Vector<VectorTestClass> myVector;
351 SC_TEST_EXPECT(vecReport.numSequences == 1);
352 vecReport.reset();
353 SC_TEST_EXPECT(myVector.resize(2));
354 SC_TEST_EXPECT(vecReport.numSequences == 4);
355 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::CONSTRUCTOR); // DEFAULT PARAM
356 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::COPY_CONSTRUCTOR); // FIRST ELEMENT
357 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::COPY_CONSTRUCTOR); // SECOND ELEMENT
358 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::DESTRUCTOR); // DEFAULT PARAM DESTRUCTOR
359 SC_TEST_EXPECT(myVector[0].toString().isEmpty());
360 SC_TEST_EXPECT(myVector[1].toString().isEmpty());
361
362 vecReport.reset();
363 SC_TEST_EXPECT(myVector.resize(3, VectorTestClass("Custom")));
364 SC_TEST_EXPECT(vecReport.numSequences == 7);
365 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::CONSTRUCTOR); // DEFAULT PARAM
366 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::MOVE_CONSTRUCTOR); // ITEM[1] CONSTRUCTOR
367 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::MOVE_CONSTRUCTOR); // ITEM[2] CONSTRUCTOR
368 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::DESTRUCTOR); // ITEM[1] MOVED_DESTRUCTOR
369 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::DESTRUCTOR); // ITEM[2] MOVED_DESTRUCTOR
370 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::COPY_CONSTRUCTOR); // ITEM[3] COPY_CONSTRUCTOR
371 // (DEFAULT PARAM)
372 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::DESTRUCTOR); // DEFAULT PARAM DESTRUCTOR
373 SC_TEST_EXPECT(myVector[0].toString().isEmpty());
374 SC_TEST_EXPECT(myVector[1].toString().isEmpty());
375 SC_TEST_EXPECT(myVector[2].toString() == StringView("Custom"));
376 vecReport.reset();
377 SC_TEST_EXPECT(myVector.resize(2));
378 SC_TEST_EXPECT(vecReport.numSequences == 3);
379 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::CONSTRUCTOR); // DEFAULT PARAM
380 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::DESTRUCTOR); // ITEM[3] DESTRUCTOR
381 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::DESTRUCTOR); // DEFAULT PARAM DESTRUCTOR
382 SC_TEST_EXPECT(myVector.resize(0));
383 vecReport.reset();
384 SC_TEST_EXPECT(myVector.resize(1));
385 SC_TEST_EXPECT(vecReport.numSequences == 3);
386 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::CONSTRUCTOR); // DEFAULT PARAM
387 SC_TEST_EXPECT(vecReport.nextOperation() == VectorTestReport::COPY_CONSTRUCTOR); // ITEM[3] COPY_CONSTRUCTOR
388 SC_TEST_EXPECT(not myVector.resize(INSANE_NUMBER));
389 }
390
391 if (test_section("class_shrink_to_fit"))
392 {
393 SC::Vector<VectorTestClass> myVector;
394 SC_TEST_EXPECT(myVector.shrink_to_fit());
395 SC_TEST_EXPECT(myVector.size() == 0);
396 SC_TEST_EXPECT(myVector.capacity() == 0);

Callers

nothing calls this directly

Calls 15

getFunction · 0.85
VectorTestClassClass · 0.85
nextOperationMethod · 0.80
reserveMethod · 0.80
toSpanMethod · 0.80
parseInt32Method · 0.80
pop_backMethod · 0.80
removeAllMethod · 0.80
resetMethod · 0.45
toStringMethod · 0.45
resizeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected