Fix build of tests on QNX.

Change-Id: Ib28e42e3eb10e26555fe392c55534f715bee5f8b
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
Rafael Roquetto 2015-03-13 11:04:36 -03:00 committed by Simon Hausmann
parent 614f37c8b5
commit 00c09aaf5b
6 changed files with 101 additions and 69 deletions

View File

@ -385,14 +385,14 @@ void tst_QtConcurrentRun::recursive()
count.store(0); count.store(0);
QThreadPool::globalInstance()->setMaxThreadCount(i); QThreadPool::globalInstance()->setMaxThreadCount(i);
recursiveRun(levels); recursiveRun(levels);
QCOMPARE(count.load(), (int)pow(2.0, levels) - 1); QCOMPARE(count.load(), (int)std::pow(2.0, levels) - 1);
} }
for (int i = 0; i < QThread::idealThreadCount(); ++i) { for (int i = 0; i < QThread::idealThreadCount(); ++i) {
count.store(0); count.store(0);
QThreadPool::globalInstance()->setMaxThreadCount(i); QThreadPool::globalInstance()->setMaxThreadCount(i);
recursiveResult(levels); recursiveResult(levels);
QCOMPARE(count.load(), (int)pow(2.0, levels) - 1); QCOMPARE(count.load(), (int)std::pow(2.0, levels) - 1);
} }
} }

View File

@ -753,7 +753,7 @@ void tst_QEasingCurve::testCbrtDouble()
if (f != 0.0) if (f != 0.0)
t = t * (t_cubic + d + d) / f; t = t * (t_cubic + d + d) / f;
double expected = pow(d, 1.0/3.0); double expected = std::pow(d, 1.0/3.0);
const qreal error = qAbs(expected - t); const qreal error = qAbs(expected - t);
@ -779,7 +779,7 @@ void tst_QEasingCurve::testCbrtFloat()
if (fac != 0.0f) if (fac != 0.0f)
t = t * (t_cubic + f + f) / fac; t = t * (t_cubic + f + f) / fac;
float expected = pow(f, float(1.0/3.0)); float expected = std::pow(f, float(1.0/3.0));
const qreal error = qAbs(expected - t); const qreal error = qAbs(expected - t);

View File

@ -275,12 +275,12 @@ void tst_QPointF::division()
{ {
{ {
QPointF p(1e-14, 1e-14); QPointF p(1e-14, 1e-14);
p = p / sqrt(dot(p, p)); p = p / std::sqrt(dot(p, p));
QCOMPARE(dot(p, p), qreal(1.0)); QCOMPARE(dot(p, p), qreal(1.0));
} }
{ {
QPointF p(1e-14, 1e-14); QPointF p(1e-14, 1e-14);
p /= sqrt(dot(p, p)); p /= std::sqrt(dot(p, p));
QCOMPARE(dot(p, p), qreal(1.0)); QCOMPARE(dot(p, p), qreal(1.0));
} }
} }

View File

@ -152,125 +152,125 @@ void tst_QWMatrix::mapping_data()
// rotations // rotations
float deg = 0.; float deg = 0.;
QTest::newRow( "rot 0 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot 0 a" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon ( QRect( 0, 0, 30, 40 ) ); << QPolygon ( QRect( 0, 0, 30, 40 ) );
deg = 0.00001f; deg = 0.00001f;
QTest::newRow( "rot 0 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot 0 b" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon ( QRect( 0, 0, 30, 40 ) ); << QPolygon ( QRect( 0, 0, 30, 40 ) );
deg = 0.; deg = 0.;
QTest::newRow( "rot 0 c" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot 0 c" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon ( QRect( 10, 20, 30, 40 ) ); << QPolygon ( QRect( 10, 20, 30, 40 ) );
deg = 0.00001f; deg = 0.00001f;
QTest::newRow( "rot 0 d" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot 0 d" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon ( QRect( 10, 20, 30, 40 ) ); << QPolygon ( QRect( 10, 20, 30, 40 ) );
#if 0 #if 0
// rotations // rotations
deg = 90.; deg = 90.;
QTest::newRow( "rotscale 90 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 90 a" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( 0, -299, 400, 300 ) ); << QPolygon( QRect( 0, -299, 400, 300 ) );
deg = 90.00001; deg = 90.00001;
QTest::newRow( "rotscale 90 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 90 b" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( 0, -299, 400, 300 ) ); << QPolygon( QRect( 0, -299, 400, 300 ) );
deg = 90.; deg = 90.;
QTest::newRow( "rotscale 90 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 90 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 200, -399, 400, 300 ) ); << QPolygon( QRect( 200, -399, 400, 300 ) );
deg = 90.00001; deg = 90.00001;
QTest::newRow( "rotscale 90 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 90 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 200, -399, 400, 300 ) ); << QPolygon( QRect( 200, -399, 400, 300 ) );
deg = 180.; deg = 180.;
QTest::newRow( "rotscale 180 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 180 a" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -299, -399, 300, 400 ) ); << QPolygon( QRect( -299, -399, 300, 400 ) );
deg = 180.000001; deg = 180.000001;
QTest::newRow( "rotscale 180 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 180 b" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -299, -399, 300, 400 ) ); << QPolygon( QRect( -299, -399, 300, 400 ) );
deg = 180.; deg = 180.;
QTest::newRow( "rotscale 180 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 180 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -399, -599, 300, 400 ) ); << QPolygon( QRect( -399, -599, 300, 400 ) );
deg = 180.000001; deg = 180.000001;
QTest::newRow( "rotscale 180 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 180 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -399, -599, 300, 400 ) ); << QPolygon( QRect( -399, -599, 300, 400 ) );
deg = 270.; deg = 270.;
QTest::newRow( "rotscale 270 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 270 a" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -399, 00, 400, 300 ) ); << QPolygon( QRect( -399, 00, 400, 300 ) );
deg = 270.0000001; deg = 270.0000001;
QTest::newRow( "rotscale 270 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 270 b" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 30, 40 ) << QRect( 0, 0, 30, 40 )
<< QPolygon( QRect( -399, 00, 400, 300 ) ); << QPolygon( QRect( -399, 00, 400, 300 ) );
deg = 270.; deg = 270.;
QTest::newRow( "rotscale 270 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 270 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -599, 100, 400, 300 ) ); << QPolygon( QRect( -599, 100, 400, 300 ) );
deg = 270.000001; deg = 270.000001;
QTest::newRow( "rotscale 270 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rotscale 270 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -599, 100, 400, 300 ) ); << QPolygon( QRect( -599, 100, 400, 300 ) );
// rotations that are not multiples of 90 degrees. mapRect returns the bounding rect here. // rotations that are not multiples of 90 degrees. mapRect returns the bounding rect here.
deg = 45; deg = 45;
QTest::newRow( "rot 45 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot 45 a" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 ) << QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( 0, -7, 14, 14 ) ); << QPolygon( QRect( 0, -7, 14, 14 ) );
QTest::newRow( "rot 45 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot 45 b" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 21, -14, 49, 49 ) ); << QPolygon( QRect( 21, -14, 49, 49 ) );
QTest::newRow( "rot 45 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rot 45 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 ) << QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( 0, -70, 141, 141 ) ); << QPolygon( QRect( 0, -70, 141, 141 ) );
QTest::newRow( "rot 45 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rot 45 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( 212, -141, 495, 495 ) ); << QPolygon( QRect( 212, -141, 495, 495 ) );
deg = -45; deg = -45;
QTest::newRow( "rot -45 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot -45 a" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 ) << QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( -7, 0, 14, 14 ) ); << QPolygon( QRect( -7, 0, 14, 14 ) );
QTest::newRow( "rot -45 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ), QTest::newRow( "rot -45 b" ) << QMatrix( std::cos( M_PI*deg/180. ), -std::sin( M_PI*deg/180. ),
sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 ) std::sin( M_PI*deg/180. ), std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -35, 21, 49, 49 ) ); << QPolygon( QRect( -35, 21, 49, 49 ) );
QTest::newRow( "rot -45 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rot -45 c" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 0, 0, 10, 10 ) << QRect( 0, 0, 10, 10 )
<< QPolygon( QRect( -70, 0, 141, 141 ) ); << QPolygon( QRect( -70, 0, 141, 141 ) );
QTest::newRow( "rot -45 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ), QTest::newRow( "rot -45 d" ) << QMatrix( 10*std::cos( M_PI*deg/180. ), -10*std::sin( M_PI*deg/180. ),
10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 ) 10*std::sin( M_PI*deg/180. ), 10*std::cos( M_PI*deg/180. ), 0, 0 )
<< QRect( 10, 20, 30, 40 ) << QRect( 10, 20, 30, 40 )
<< QPolygon( QRect( -353, 212, 495, 495 ) ); << QPolygon( QRect( -353, 212, 495, 495 ) );
#endif #endif

View File

@ -75,17 +75,13 @@ private slots:
void rangeReplace2(); void rangeReplace2();
void matchReplace2(); void matchReplace2();
#ifdef HAVE_JSC
void simpleFindJSC(); void simpleFindJSC();
void rangeReplaceJSC(); void rangeReplaceJSC();
void matchReplaceJSC(); void matchReplaceJSC();
#endif
#ifdef HAVE_BOOST
void simpleFindBoost(); void simpleFindBoost();
void rangeReplaceBoost(); void rangeReplaceBoost();
void matchReplaceBoost(); void matchReplaceBoost();
#endif
/* those apply an (incorrect) regexp on entire source /* those apply an (incorrect) regexp on entire source
(this main.cpp). JSC appears to handle this (this main.cpp). JSC appears to handle this
@ -95,14 +91,10 @@ private slots:
void horribleReplace1(); void horribleReplace1();
void horribleReplace2(); void horribleReplace2();
void horribleWrongReplace2(); void horribleWrongReplace2();
#ifdef HAVE_JSC
void horribleWrongReplaceJSC(); void horribleWrongReplaceJSC();
void horribleReplaceJSC(); void horribleReplaceJSC();
#endif
#ifdef HAVE_BOOST
void horribleWrongReplaceBoost(); void horribleWrongReplaceBoost();
void horribleReplaceBoost(); void horribleReplaceBoost();
#endif
private: private:
QString str1; QString str1;
QString str2; QString str2;
@ -451,9 +443,9 @@ void tst_qregexp::horribleReplace2()
} }
QCOMPARE(r, QString("1.2.3")); QCOMPARE(r, QString("1.2.3"));
} }
#ifdef HAVE_JSC
void tst_qregexp::simpleFindJSC() void tst_qregexp::simpleFindJSC()
{ {
#ifdef HAVE_JSC
int numr; int numr;
const char * errmsg=" "; const char * errmsg=" ";
QString rxs("happy"); QString rxs("happy");
@ -467,10 +459,14 @@ void tst_qregexp::simpleFindJSC()
jsRegExpFree(rx); jsRegExpFree(rx);
QCOMPARE(numr, 1); QCOMPARE(numr, 1);
QCOMPARE(offsetVector[0], 11); QCOMPARE(offsetVector[0], 11);
#else
QSKIP("JSC is not enabled for this platform");
#endif
} }
void tst_qregexp::rangeReplaceJSC() void tst_qregexp::rangeReplaceJSC()
{ {
#ifdef HAVE_JSC
QScriptValue r; QScriptValue r;
QScriptEngine engine; QScriptEngine engine;
engine.globalObject().setProperty("s", str1); engine.globalObject().setProperty("s", str1);
@ -480,10 +476,14 @@ void tst_qregexp::rangeReplaceJSC()
r = replaceFunc.call(QScriptValue()); r = replaceFunc.call(QScriptValue());
} }
QCOMPARE(r.toString(), QString("W- -r- -ll h-ppy monk-ys")); QCOMPARE(r.toString(), QString("W- -r- -ll h-ppy monk-ys"));
#else
QSKIP("JSC is not enabled for this platform");
#endif
} }
void tst_qregexp::matchReplaceJSC() void tst_qregexp::matchReplaceJSC()
{ {
#ifdef HAVE_JSC
QScriptValue r; QScriptValue r;
QScriptEngine engine; QScriptEngine engine;
engine.globalObject().setProperty("s", str1); engine.globalObject().setProperty("s", str1);
@ -493,10 +493,14 @@ void tst_qregexp::matchReplaceJSC()
r = replaceFunc.call(QScriptValue()); r = replaceFunc.call(QScriptValue());
} }
QCOMPARE(r.toString(), QString("eaeaae")); QCOMPARE(r.toString(), QString("eaeaae"));
#else
QSKIP("JSC is not enabled for this platform");
#endif
} }
void tst_qregexp::horribleWrongReplaceJSC() void tst_qregexp::horribleWrongReplaceJSC()
{ {
#ifdef HAVE_JSC
QScriptValue r; QScriptValue r;
QScriptEngine engine; QScriptEngine engine;
engine.globalObject().setProperty("s", str2); engine.globalObject().setProperty("s", str2);
@ -506,10 +510,14 @@ void tst_qregexp::horribleWrongReplaceJSC()
r = replaceFunc.call(QScriptValue()); r = replaceFunc.call(QScriptValue());
} }
QCOMPARE(r.toString(), str2); QCOMPARE(r.toString(), str2);
#else
QSKIP("JSC is not enabled for this platform");
#endif
} }
void tst_qregexp::horribleReplaceJSC() void tst_qregexp::horribleReplaceJSC()
{ {
#ifdef HAVE_JSC
QScriptValue r; QScriptValue r;
QScriptEngine engine; QScriptEngine engine;
// the m flag doesn't actually work here; dunno // the m flag doesn't actually work here; dunno
@ -520,11 +528,14 @@ void tst_qregexp::horribleReplaceJSC()
r = replaceFunc.call(QScriptValue()); r = replaceFunc.call(QScriptValue());
} }
QCOMPARE(r.toString(), QString("1.2.3")); QCOMPARE(r.toString(), QString("1.2.3"));
} #else
QSKIP("JSC is not enabled for this platform");
#endif #endif
}
void tst_qregexp::simpleFindBoost()
{
#ifdef HAVE_BOOST #ifdef HAVE_BOOST
void tst_qregexp::simpleFindBoost(){
int roff; int roff;
boost::regex rx ("happy", boost::regex_constants::perl); boost::regex rx ("happy", boost::regex_constants::perl);
std::string s = str1.toStdString(); std::string s = str1.toStdString();
@ -538,10 +549,15 @@ void tst_qregexp::simpleFindBoost(){
roff = (what[0].first)-start; roff = (what[0].first)-start;
} }
QCOMPARE(roff, 11); QCOMPARE(roff, 11);
#else
QSKIP("Boost is not enabled for this platform");
#endif
} }
void tst_qregexp::rangeReplaceBoost() void tst_qregexp::rangeReplaceBoost()
{ {
#ifdef HAVE_BOOST
boost::regex pattern ("[a-f]", boost::regex_constants::perl); boost::regex pattern ("[a-f]", boost::regex_constants::perl);
std::string s = str1.toStdString(); std::string s = str1.toStdString();
std::string r; std::string r;
@ -549,10 +565,14 @@ void tst_qregexp::rangeReplaceBoost()
r = boost::regex_replace (s, pattern, "-"); r = boost::regex_replace (s, pattern, "-");
} }
QCOMPARE(r, std::string("W- -r- -ll h-ppy monk-ys")); QCOMPARE(r, std::string("W- -r- -ll h-ppy monk-ys"));
#else
QSKIP("Boost is not enabled for this platform");
#endif
} }
void tst_qregexp::matchReplaceBoost() void tst_qregexp::matchReplaceBoost()
{ {
#ifdef HAVE_BOOST
boost::regex pattern ("[^a-f]*([a-f]+)[^a-f]*",boost::regex_constants::perl); boost::regex pattern ("[^a-f]*([a-f]+)[^a-f]*",boost::regex_constants::perl);
std::string s = str1.toStdString(); std::string s = str1.toStdString();
std::string r; std::string r;
@ -560,10 +580,14 @@ void tst_qregexp::matchReplaceBoost()
r = boost::regex_replace (s, pattern, "$1"); r = boost::regex_replace (s, pattern, "$1");
} }
QCOMPARE(r, std::string("eaeaae")); QCOMPARE(r, std::string("eaeaae"));
#else
QSKIP("Boost is not enabled for this platform");
#endif
} }
void tst_qregexp::horribleWrongReplaceBoost() void tst_qregexp::horribleWrongReplaceBoost()
{ {
#ifdef HAVE_BOOST
boost::regex pattern (".*#""define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\".*", boost::regex_constants::perl); boost::regex pattern (".*#""define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\".*", boost::regex_constants::perl);
std::string s = str2.toStdString(); std::string s = str2.toStdString();
std::string r; std::string r;
@ -571,10 +595,14 @@ void tst_qregexp::horribleWrongReplaceBoost()
r = boost::regex_replace (s, pattern, "$1.$2.$3"); r = boost::regex_replace (s, pattern, "$1.$2.$3");
} }
QCOMPARE(r, s); QCOMPARE(r, s);
#else
QSKIP("Boost is not enabled for this platform");
#endif
} }
void tst_qregexp::horribleReplaceBoost() void tst_qregexp::horribleReplaceBoost()
{ {
#ifdef HAVE_BOOST
boost::regex pattern (".*#""define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+).*", boost::regex_constants::perl); boost::regex pattern (".*#""define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+).*", boost::regex_constants::perl);
std::string s = str2.toStdString(); std::string s = str2.toStdString();
std::string r; std::string r;
@ -582,8 +610,10 @@ void tst_qregexp::horribleReplaceBoost()
r = boost::regex_replace (s, pattern, "$1.$2.$3"); r = boost::regex_replace (s, pattern, "$1.$2.$3");
} }
QCOMPARE(r, std::string("1.2.3")); QCOMPARE(r, std::string("1.2.3"));
#else
QSKIP("Boost is not enabled for this platform");
#endif
} }
#endif //HAVE_BOOST
QTEST_MAIN(tst_qregexp) QTEST_MAIN(tst_qregexp)

View File

@ -11,9 +11,11 @@ qtHaveModule(script):!pcre {
QT += script QT += script
} }
exists($$[QT_SYSROOT]/usr/include/boost/regex.hpp) { !qnx {
DEFINES+=HAVE_BOOST exists($$[QT_SYSROOT]/usr/include/boost/regex.hpp) {
LIBS+=-lboost_regex DEFINES += HAVE_BOOST
LIBS += -lboost_regex
}
} }
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0