mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Use std::shuffle instead of std::random_shuffle
mcgrathr points out in https://chromium-review.googlesource.com/1172090 that std::random_shuffle is deprecated in C++14 and removed in C++17. Rather than having mini_chromium mimic Chromium’s base by providing RandomShuffle (Chromium 5de2157f1e7f), just use the standard library’s std::shuffle with mt19937(random_generator). Change-Id: I8c2b3101bf324350351dba9edda1ba230b1c6710 Reviewed-on: https://chromium-review.googlesource.com/1176122 Reviewed-by: Robert Sesek <rsesek@chromium.org> Commit-Queue: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
3ab5d5eff2
commit
5c6e19f000
@ -18,11 +18,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <random>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/numerics/safe_conversions.h"
|
#include "base/numerics/safe_conversions.h"
|
||||||
#include "base/rand_util.h"
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test/scoped_temp_dir.h"
|
#include "test/scoped_temp_dir.h"
|
||||||
@ -218,11 +218,8 @@ TEST(PruneCrashReports, PruneOrder) {
|
|||||||
temp.creation_time = NDaysAgo(i * 10);
|
temp.creation_time = NDaysAgo(i * 10);
|
||||||
reports.push_back(temp);
|
reports.push_back(temp);
|
||||||
}
|
}
|
||||||
// The randomness from std::rand() is not, so use a better rand() instead.
|
std::mt19937 urng(std::random_device{}());
|
||||||
const auto random_generator = [](ptrdiff_t rand_max) {
|
std::shuffle(reports.begin(), reports.end(), urng);
|
||||||
return base::RandInt(0, base::checked_cast<int>(rand_max) - 1);
|
|
||||||
};
|
|
||||||
std::random_shuffle(reports.begin(), reports.end(), random_generator);
|
|
||||||
std::vector<CrashReportDatabase::Report> pending_reports(
|
std::vector<CrashReportDatabase::Report> pending_reports(
|
||||||
reports.begin(), reports.begin() + 5);
|
reports.begin(), reports.begin() + 5);
|
||||||
std::vector<CrashReportDatabase::Report> completed_reports(
|
std::vector<CrashReportDatabase::Report> completed_reports(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user