diff options
Diffstat (limited to 'tests/auto/gui')
4 files changed, 16 insertions, 14 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 235d53f3c1..54eb8ab99c 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -33,6 +33,7 @@ #include <qimagereader.h> #include <qlist.h> #include <qmatrix.h> +#include <qrandom.h> #include <stdio.h> #include <qpainter.h> @@ -1754,7 +1755,7 @@ void tst_QImage::smoothScale2() static inline int rand8() { - return int(256. * (qrand() / (RAND_MAX + 1.0))); + return QRandomGenerator::global()->bounded(256); } void tst_QImage::smoothScale3_data() diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 779783d5ec..b8243a2b54 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -45,6 +45,7 @@ #include <qdesktopwidget.h> #endif #include <qpixmap.h> +#include <qrandom.h> #include <private/qdrawhelper_p.h> #include <qpainter.h> @@ -3052,7 +3053,7 @@ void tst_QPainter::fpe_steepSlopes_data() qreal randf() { - return rand() / (RAND_MAX + 1.0); + return QRandomGenerator::global()->bounded(1.0); } QPointF randInRect(const QRectF &rect) diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp index 14ba9c5c84..93035af7d3 100644 --- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp +++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp @@ -35,6 +35,7 @@ #include <qpolygon.h> #include <qdebug.h> #include <qpainter.h> +#include <qrandom.h> #include <math.h> @@ -423,8 +424,8 @@ void tst_QPathClipper::clip() static inline QPointF randomPointInRect(const QRectF &rect) { - qreal rx = qrand() / (RAND_MAX + 1.); - qreal ry = qrand() / (RAND_MAX + 1.); + qreal rx = QRandomGenerator::global()->bounded(1.0); + qreal ry = QRandomGenerator::global()->bounded(1.0); return QPointF(rect.left() + rx * rect.width(), rect.top() + ry * rect.height()); diff --git a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp index ca01e83dbe..39f5e9ecc3 100644 --- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp +++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp @@ -145,7 +145,7 @@ void tst_QTextPieceTable::insertion3() { QString compare; for (int i = 0; i < 20000; ++i) { - int pos = rand() % (i+1); + int pos = QRandomGenerator::global()->bounded(i+1); QChar c((unsigned short)(i & 0xff) + 1); QString str; str += c; @@ -159,7 +159,7 @@ void tst_QTextPieceTable::insertion4() { QString compare; for (int i = 0; i < 20000; ++i) { - int pos = rand() % (i+1); + int pos = QRandomGenerator::global()->generate() % (i+1); QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; @@ -178,7 +178,7 @@ void tst_QTextPieceTable::insertion5() { QString compare; for (int i = 0; i < 20000; ++i) { - int pos = rand() % (i+1); + int pos = QRandomGenerator::global()->generate() % (i+1); QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; @@ -236,8 +236,8 @@ void tst_QTextPieceTable::removal3() QString compare; int l = 0; for (int i = 0; i < 20000; ++i) { - bool remove = l && (rand() % 2); - int pos = rand() % (remove ? l : (l+1)); + bool remove = l && (QRandomGenerator::global()->bounded(2)); + int pos = QRandomGenerator::global()->bounded(remove ? l : (l+1)); QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; @@ -263,8 +263,8 @@ void tst_QTextPieceTable::removal4() QString compare; int l = 0; for (int i = 0; i < 20000; ++i) { - bool remove = l && (rand() % 2); - int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0; + bool remove = l && (QRandomGenerator::global()->bounded(2)); + int pos = (l > 1) ? QRandomGenerator::global()->bounded(remove ? l-1 : l) : 0; QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; if (c != 'a') { @@ -472,13 +472,12 @@ void tst_QTextPieceTable::undoRedo10() void tst_QTextPieceTable::undoRedo11() { - srand(3); const int loops = 20; QString compare; int l = 0; for (int i = 0; i < loops; ++i) { - bool remove = l && (rand() % 2); - int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0; + bool remove = l && (QRandomGenerator::global()->bounded(2)); + int pos = (l > 1) ? QRandomGenerator::global()->bounded(remove ? l-1 : l) : 0; QChar c((unsigned short)((i % 26) + (i>25?'A':'a'))); QString str; str += c; |