aboutsummaryrefslogtreecommitdiffstats
path: root/util/random/random_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/random/random_ut.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/random/random_ut.cpp')
-rw-r--r--util/random/random_ut.cpp176
1 files changed, 88 insertions, 88 deletions
diff --git a/util/random/random_ut.cpp b/util/random/random_ut.cpp
index 20db587463..30427676f3 100644
--- a/util/random/random_ut.cpp
+++ b/util/random/random_ut.cpp
@@ -1,15 +1,15 @@
-#include "random.h"
-
+#include "random.h"
+
#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/ylimits.h>
-template <class T>
-static inline void AssertRange(T v, T r1, T r2) {
- UNIT_ASSERT(v >= r1);
- UNIT_ASSERT(v < r2);
-}
-
+template <class T>
+static inline void AssertRange(T v, T r1, T r2) {
+ UNIT_ASSERT(v >= r1);
+ UNIT_ASSERT(v < r2);
+}
+
Y_UNIT_TEST_SUITE(TRandomNumberTest) {
template <typename T>
void TestAll(T n) {
@@ -55,24 +55,24 @@ Y_UNIT_TEST_SUITE(TRandomNumberTest) {
TestType<unsigned long>();
TestType<unsigned long long>();
}
-
+
Y_UNIT_TEST(TestRandomNumberFloat) {
- for (size_t i = 0; i < 1000; ++i) {
- AssertRange<float>(RandomNumber<float>(), 0.0, 1.0);
- }
- }
-
+ for (size_t i = 0; i < 1000; ++i) {
+ AssertRange<float>(RandomNumber<float>(), 0.0, 1.0);
+ }
+ }
+
Y_UNIT_TEST(TestRandomNumberDouble) {
- for (size_t i = 0; i < 1000; ++i) {
- AssertRange<double>(RandomNumber<double>(), 0.0, 1.0);
- }
- }
-
+ for (size_t i = 0; i < 1000; ++i) {
+ AssertRange<double>(RandomNumber<double>(), 0.0, 1.0);
+ }
+ }
+
Y_UNIT_TEST(TestRandomNumberLongDouble) {
- for (size_t i = 0; i < 1000; ++i) {
- AssertRange<long double>(RandomNumber<long double>(), 0.0, 1.0);
- }
- }
+ for (size_t i = 0; i < 1000; ++i) {
+ AssertRange<long double>(RandomNumber<long double>(), 0.0, 1.0);
+ }
+ }
Y_UNIT_TEST(TestBoolean) {
while (RandomNumber<bool>()) {
@@ -84,71 +84,71 @@ Y_UNIT_TEST_SUITE(TRandomNumberTest) {
Y_UNIT_TEST(TestResetSeed) {
SetRandomSeed(42);
for (const ui32 el : {
- 102,
- 179,
- 92,
- 14,
- 106,
- 71,
- 188,
- 20,
- 102,
- 121,
- 210,
- 214,
- 74,
- 202,
- 87,
- 116,
- 99,
- 103,
- 151,
- 130,
- 149,
- 52,
- 1,
- 87,
- 235,
- 157,
- 37,
- 129,
- 191,
- 187,
- 20,
- 160,
- 203,
- 57,
- 21,
- 252,
- 235,
- 88,
- 48,
- 218,
- 58,
- 254,
- 169,
- 255,
- 219,
- 187,
- 207,
- 14,
- 189,
- 189,
- 174,
- 189,
- 50,
- 107,
- 54,
- 243,
- 63,
- 248,
- 130,
- 228,
- 50,
- 134,
- 20,
- 72,
- }) {
+ 102,
+ 179,
+ 92,
+ 14,
+ 106,
+ 71,
+ 188,
+ 20,
+ 102,
+ 121,
+ 210,
+ 214,
+ 74,
+ 202,
+ 87,
+ 116,
+ 99,
+ 103,
+ 151,
+ 130,
+ 149,
+ 52,
+ 1,
+ 87,
+ 235,
+ 157,
+ 37,
+ 129,
+ 191,
+ 187,
+ 20,
+ 160,
+ 203,
+ 57,
+ 21,
+ 252,
+ 235,
+ 88,
+ 48,
+ 218,
+ 58,
+ 254,
+ 169,
+ 255,
+ 219,
+ 187,
+ 207,
+ 14,
+ 189,
+ 189,
+ 174,
+ 189,
+ 50,
+ 107,
+ 54,
+ 243,
+ 63,
+ 248,
+ 130,
+ 228,
+ 50,
+ 134,
+ 20,
+ 72,
+ }) {
UNIT_ASSERT_EQUAL(RandomNumber<ui32>(1 << 8), el);
}
}