fix: replaced qrand() to QrandomGenerator due to deprecation

It fixes this and similar warnings:
```
qt/test/trafficgraphdatatests.cpp:145:23: warning: ‘int qrand()’ is deprecated: use QRandomGenerator instead [-Wdeprecated-declarations]
  145 |         int in = qrand() % 1000;
      |                  ~~~~~^~
```

Call of `qsrand` is not needed because QRandomGenerator is already randomly initialized
This commit is contained in:
Konstantin Akimov 2023-11-06 00:23:30 +07:00 committed by PastaPastaPasta
parent f2e8431f4a
commit 0905bed3fb

View File

@ -6,7 +6,7 @@
#include <qt/trafficgraphdata.h>
#include <algorithm>
#include <sstream>
#include <QTime>
#include <QRandomGenerator>
void TrafficGraphDataTests::simpleCurrentSampleQueueTests()
{
@ -137,13 +137,12 @@ void compareQueues(const TrafficGraphData::SampleQueue& expected, const TrafficG
void testRangeSwitch(TrafficGraphData::GraphRange baseRange, TrafficGraphData::GraphRange toRange,int size)
{
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
TrafficGraphData trafficGraphDataBase(baseRange);
TrafficGraphData trafficGraphData(toRange);
auto* generator = QRandomGenerator::global();
for (int i = 1; i <= size; i++){
int in = qrand() % 1000;
int out = qrand() % 1000;
int in = generator->generate() % 1000;
int out = generator->generate() % 1000;
trafficGraphData.update(TrafficSample(in, out));
trafficGraphDataBase.update(TrafficSample(in, out));
}