/
dieoska
/
ddnet
Обзор
Документация
Войти
/
dieoska
/
ddnet
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/test/secure_random_test.cpp
35 строк
558 B
ChillerDragon
Add test suffix
22 ноя 2025, 16:34
22 ноя 2025, 16:34
7b943a4
Код
Авторство
О чём код?
#include "test.h" #include <base/system.h> #include <gtest/gtest.h> TEST(SecureRandom, Fill) { unsigned int Bits = 0; while(~Bits) { unsigned int Random; secure_random_fill(&Random, sizeof(Random)); Bits |= Random; } } TEST(SecureRandom, Below1) { EXPECT_EQ(secure_rand_below(1), 0); } TEST(SecureRandom, Below) { const int BOUNDS[] = {2, 3, 4, 5, 10, 100, 127, 128, 129}; for(auto Below : BOUNDS) { for(int j = 0; j < 10; j++) { int Random = secure_rand_below(Below); EXPECT_GE(Random, 0); EXPECT_LT(Random, Below); } } }