tests/auto/qstring/tst_qstring.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   205     void sprintfZU() const;
   205     void sprintfZU() const;
   206     void repeatedSignature() const;
   206     void repeatedSignature() const;
   207     void repeated() const;
   207     void repeated() const;
   208     void repeated_data() const;
   208     void repeated_data() const;
   209     void task262677remove();
   209     void task262677remove();
       
   210     void QTBUG10404_compareRef();
   210 };
   211 };
   211 
   212 
   212 typedef QList<int> IntList;
   213 typedef QList<int> IntList;
   213 
   214 
   214 Q_DECLARE_METATYPE(QList<QVariant>)
   215 Q_DECLARE_METATYPE(QList<QVariant>)
  4826     QString driveName = QLatin1String("V:\\blahblah\\more_blahblah\\");
  4827     QString driveName = QLatin1String("V:\\blahblah\\more_blahblah\\");
  4827     driveName.remove(2, INT_MAX); // should be "V:" - instead, it's "V::\\blahblah\\more_blahblah\\"
  4828     driveName.remove(2, INT_MAX); // should be "V:" - instead, it's "V::\\blahblah\\more_blahblah\\"
  4828     QVERIFY(driveName == QLatin1String("V:"));
  4829     QVERIFY(driveName == QLatin1String("V:"));
  4829 }
  4830 }
  4830 
  4831 
       
  4832 void tst_QString::QTBUG10404_compareRef()
       
  4833 {
       
  4834     QString a = "ABCDEFGH";
       
  4835 
       
  4836     QCOMPARE(QStringRef(&a, 1, 2).compare(QLatin1String("BC")), 0);
       
  4837     QVERIFY(QStringRef(&a, 1, 2).compare(QLatin1String("BCD")) < 0);
       
  4838     QCOMPARE(QStringRef(&a, 1, 2).compare(QLatin1String("Bc"), Qt::CaseInsensitive), 0);
       
  4839     QVERIFY(QStringRef(&a, 1, 2).compare(QLatin1String("bCD"), Qt::CaseInsensitive) < 0);
       
  4840 
       
  4841     QCOMPARE(QStringRef(&a, 1, 2).compare(QString::fromLatin1("BC")), 0);
       
  4842     QVERIFY(QStringRef(&a, 1, 2).compare(QString::fromLatin1("BCD")) < 0);
       
  4843     QCOMPARE(QStringRef(&a, 1, 2).compare(QString::fromLatin1("Bc"), Qt::CaseInsensitive), 0);
       
  4844     QVERIFY(QStringRef(&a, 1, 2).compare(QString::fromLatin1("bCD"), Qt::CaseInsensitive) < 0);
       
  4845 
       
  4846     QCOMPARE(QString::fromLatin1("BC").compare(QStringRef(&a, 1, 2)), 0);
       
  4847     QVERIFY(QString::fromLatin1("BCD").compare(QStringRef(&a, 1, 2)) > 0);
       
  4848     QCOMPARE(QString::fromLatin1("Bc").compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive), 0);
       
  4849     QVERIFY(QString::fromLatin1("bCD").compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive) > 0);
       
  4850 
       
  4851     QCOMPARE(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 2)), 0);
       
  4852     QVERIFY(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 3)) < 0);
       
  4853     QCOMPARE(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive), 0);
       
  4854     QVERIFY(QStringRef(&a, 1, 2).compare(QStringRef(&a, 1, 3), Qt::CaseInsensitive) < 0);
       
  4855 
       
  4856     QString a2 = "ABCDEFGh";
       
  4857     QCOMPARE(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 2)), 0);
       
  4858     QVERIFY(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 3)) < 0);
       
  4859     QCOMPARE(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 2), Qt::CaseInsensitive), 0);
       
  4860     QVERIFY(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 3), Qt::CaseInsensitive) < 0);
       
  4861 }
       
  4862 
       
  4863 
  4831 
  4864 
  4832 QTEST_APPLESS_MAIN(tst_QString)
  4865 QTEST_APPLESS_MAIN(tst_QString)
  4833 
  4866 
  4834 #include "tst_qstring.moc"
  4867 #include "tst_qstring.moc"