void inheritanceExample() { // create an example MyBaseClass object MyBaseClass baseA; baseA.setProtectedInt(1); baseA.setPrivateInt(2); std::cout << "Printing baseA:" << std::endl; baseA.print(); std::cout << std::endl; // create an example MyDerivedClass object MyDerivedClass derivedA; derivedA.setProtectedInt(10); derivedA.setPrivateInt(11); derivedA.setAdditionalPrivateInt(12); std::cout << "Printing derivedA:" << std::endl; derivedA.print(); std::cout << std::endl; // create a MyBaseClass object from the derivedA object MyBaseClass baseB(derivedA); // using automatic copy constructor std::cout << "Printing baseB:" << std::endl; baseB.print(); std::cout << std::endl; }
void tst_QLine::testIntersection_data() { QTest::addColumn<double>("xa1"); QTest::addColumn<double>("ya1"); QTest::addColumn<double>("xa2"); QTest::addColumn<double>("ya2"); QTest::addColumn<double>("xb1"); QTest::addColumn<double>("yb1"); QTest::addColumn<double>("xb2"); QTest::addColumn<double>("yb2"); QTest::addColumn<int>("type"); QTest::addColumn<double>("ix"); QTest::addColumn<double>("iy"); QTest::newRow("parallel") << 1.0 << 1.0 << 3.0 << 4.0 << 5.0 << 6.0 << 7.0 << 9.0 << int(QLineF::NoIntersection) << 0.0 << 0.0; QTest::newRow("unbounded") << 1.0 << 1.0 << 5.0 << 5.0 << 0.0 << 4.0 << 3.0 << 4.0 << int(QLineF::UnboundedIntersection) << 4.0 << 4.0; QTest::newRow("bounded") << 1.0 << 1.0 << 5.0 << 5.0 << 0.0 << 4.0 << 5.0 << 4.0 << int(QLineF::BoundedIntersection) << 4.0 << 4.0; QTest::newRow("almost vertical") << 0.0 << 10.0 << 20.0000000000001 << 10.0 << 10.0 << 0.0 << 10.0 << 20.0 << int(QLineF::BoundedIntersection) << 10.0 << 10.0; QTest::newRow("almost horizontal") << 0.0 << 10.0 << 20.0 << 10.0 << 10.0000000000001 << 0.0 << 10.0 << 20.0 << int(QLineF::BoundedIntersection) << 10.0 << 10.0; QTest::newRow("long vertical") << 100.1599256468623 << 100.7861905065196 << 100.1599256468604 << -9999.78619050651 << 10.0 << 50.0 << 190.0 << 50.0 << int(QLineF::BoundedIntersection) << 100.1599256468622 << 50.0; QLineF baseA(0, -50, 0, 50); QLineF baseB(-50, 0, 50, 0); for (int i = 0; i < 1000; ++i) { QLineF a = QLineF::fromPolar(50, i); a.setP1(-a.p2()); QLineF b = QLineF::fromPolar(50, i * 0.997 + 90); b.setP1(-b.p2()); // make the qFuzzyCompare be a bit more lenient a = a.translated(1, 1); b = b.translated(1, 1); QTest::newRow(("rotation-" + QByteArray::number(i)).constData()) << (double)a.x1() << (double)a.y1() << (double)a.x2() << (double)a.y2() << (double)b.x1() << (double)b.y1() << (double)b.x2() << (double)b.y2() << int(QLineF::BoundedIntersection) << 1.0 << 1.0; } }