A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git]
/
src
/
xbt
/
dict_test.cpp
diff --git
a/src/xbt/dict_test.cpp
b/src/xbt/dict_test.cpp
index
ed105ea
..
168a9b4
100644
(file)
--- a/
src/xbt/dict_test.cpp
+++ b/
src/xbt/dict_test.cpp
@@
-8,9
+8,9
@@
#include "xbt/dict.h"
#include "simgrid/Exception.hpp"
#include "xbt/dict.h"
#include "simgrid/Exception.hpp"
+#include "xbt/random.hpp"
#include <cstdio>
#include <cstring>
#include <cstdio>
#include <cstring>
-#include <random>
#include "catch.hpp"
#include "catch.hpp"
@@
-52,7
+52,7
@@
static xbt_dict_t new_fixture()
static void search_ext(const_xbt_dict_t head, const char* key, const char* data)
{
INFO("Search " << STR(key));
static void search_ext(const_xbt_dict_t head, const char* key, const char* data)
{
INFO("Search " << STR(key));
-
char* found = (char*)xbt_dict_get_or_null(head, key
);
+
auto* found = static_cast<char*>(xbt_dict_get_or_null(head, key)
);
INFO("Found " << STR(found));
if (data) {
REQUIRE(found); // data do not match expectations: found null while searching for data
INFO("Found " << STR(found));
if (data) {
REQUIRE(found); // data do not match expectations: found null while searching for data
@@
-264,9
+264,6
@@
TEST_CASE("xbt::dict: dict data container", "dict")
SECTION("Crash test")
{
SECTION("Crash test")
{
- std::random_device rd;
- std::default_random_engine rnd_engine(rd());
-
for (int i = 0; i < 10; i++) {
INFO("CRASH test number " << i + 1 << " (" << 10 - i - 1 << " to go)");
INFO("Fill the struct, count its elems and frees the structure");
for (int i = 0; i < 10; i++) {
INFO("CRASH test number " << i + 1 << " (" << 10 - i - 1 << " to go)");
INFO("Fill the struct, count its elems and frees the structure");
@@
-274,11
+271,11
@@
TEST_CASE("xbt::dict: dict data container", "dict")
xbt_dict_t head = xbt_dict_new_homogeneous(free);
for (int j = 0; j < 1000; j++) {
const char* data = nullptr;
xbt_dict_t head = xbt_dict_new_homogeneous(free);
for (int j = 0; j < 1000; j++) {
const char* data = nullptr;
-
char* key = (char*)xbt_malloc(SIZEOFKEY
);
+
auto* key = static_cast<char*>(xbt_malloc(SIZEOFKEY)
);
do {
for (int k = 0; k < SIZEOFKEY - 1; k++) {
do {
for (int k = 0; k < SIZEOFKEY - 1; k++) {
- key[k] =
rnd_engine() % ('z' - 'a') + 'a'
;
+ key[k] =
simgrid::xbt::random::uniform_int('a', 'z')
;
}
key[SIZEOFKEY - 1] = '\0';
data = (char*)xbt_dict_get_or_null(head, key);
}
key[SIZEOFKEY - 1] = '\0';
data = (char*)xbt_dict_get_or_null(head, key);
@@
-298,7
+295,7
@@
TEST_CASE("xbt::dict: dict data container", "dict")
xbt_dict_t head = xbt_dict_new_homogeneous(&free);
INFO("Fill " << NB_ELM << " elements, with keys being the number of element");
for (int j = 0; j < NB_ELM; j++) {
xbt_dict_t head = xbt_dict_new_homogeneous(&free);
INFO("Fill " << NB_ELM << " elements, with keys being the number of element");
for (int j = 0; j < NB_ELM; j++) {
-
char* key = (char*)xbt_malloc(10
);
+
auto* key = static_cast<char*>(xbt_malloc(10)
);
snprintf(key, 10, "%d", j);
xbt_dict_set(head, key, key);
snprintf(key, 10, "%d", j);
xbt_dict_set(head, key, key);
@@
-308,7
+305,7
@@
TEST_CASE("xbt::dict: dict data container", "dict")
INFO("There is " << countelems(head) << " elements");
INFO("Search my " << NB_ELM << " elements 20 times");
INFO("There is " << countelems(head) << " elements");
INFO("Search my " << NB_ELM << " elements 20 times");
-
char* key = (char*)xbt_malloc(10
);
+
auto* key = static_cast<char*>(xbt_malloc(10)
);
for (int i = 0; i < 20; i++) {
for (int j = 0; j < NB_ELM; j++) {
snprintf(key, 10, "%d", j);
for (int i = 0; i < 20; i++) {
for (int j = 0; j < NB_ELM; j++) {
snprintf(key, 10, "%d", j);