aboutsummaryrefslogtreecommitdiffstats
path: root/util/random/common_ops_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/common_ops_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/common_ops_ut.cpp')
-rw-r--r--util/random/common_ops_ut.cpp124
1 files changed, 62 insertions, 62 deletions
diff --git a/util/random/common_ops_ut.cpp b/util/random/common_ops_ut.cpp
index 3610b5d2ff..905912bd1e 100644
--- a/util/random/common_ops_ut.cpp
+++ b/util/random/common_ops_ut.cpp
@@ -1,69 +1,69 @@
-#include "common_ops.h"
-#include "random.h"
-
+#include "common_ops.h"
+#include "random.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/digest/numeric.h>
-
-#include <random>
-
+
+#include <util/digest/numeric.h>
+
+#include <random>
+
Y_UNIT_TEST_SUITE(TestCommonRNG) {
- template <class T>
- struct TRng: public TCommonRNG<T, TRng<T>> {
+ template <class T>
+ struct TRng: public TCommonRNG<T, TRng<T>> {
inline T GenRand() noexcept {
- return IntHash(C_++);
- }
-
- T C_ = RandomNumber<T>();
- };
-
+ return IntHash(C_++);
+ }
+
+ T C_ = RandomNumber<T>();
+ };
+
Y_UNIT_TEST(TestUniform1) {
- TRng<ui32> r;
-
- for (size_t i = 0; i < 1000; ++i) {
- UNIT_ASSERT(r.Uniform(10) < 10);
- }
- }
-
+ TRng<ui32> r;
+
+ for (size_t i = 0; i < 1000; ++i) {
+ UNIT_ASSERT(r.Uniform(10) < 10);
+ }
+ }
+
Y_UNIT_TEST(TestUniform2) {
- TRng<ui32> r;
-
- for (size_t i = 0; i < 1000; ++i) {
- UNIT_ASSERT(r.Uniform(1) == 0);
- }
- }
-
+ TRng<ui32> r;
+
+ for (size_t i = 0; i < 1000; ++i) {
+ UNIT_ASSERT(r.Uniform(1) == 0);
+ }
+ }
+
Y_UNIT_TEST(TestUniform3) {
- TRng<ui32> r;
-
- for (size_t i = 0; i < 1000; ++i) {
- auto x = r.Uniform(100, 200);
-
- UNIT_ASSERT(x >= 100);
- UNIT_ASSERT(x < 200);
- }
- }
-
+ TRng<ui32> r;
+
+ for (size_t i = 0; i < 1000; ++i) {
+ auto x = r.Uniform(100, 200);
+
+ UNIT_ASSERT(x >= 100);
+ UNIT_ASSERT(x < 200);
+ }
+ }
+
Y_UNIT_TEST(TestStlCompatibility) {
- {
- TRng<ui32> r;
- r.C_ = 17;
- std::normal_distribution<float> nd(0, 1);
- UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.877167, 0.01);
- }
-
- {
- TRng<ui64> r;
- r.C_ = 17;
- std::normal_distribution<double> nd(0, 1);
- UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.5615566731, 0.01);
- }
-
- {
- TRng<ui16> r;
- r.C_ = 17;
- std::normal_distribution<long double> nd(0, 1);
- UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.430375088, 0.01);
- }
- }
-}
+ {
+ TRng<ui32> r;
+ r.C_ = 17;
+ std::normal_distribution<float> nd(0, 1);
+ UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.877167, 0.01);
+ }
+
+ {
+ TRng<ui64> r;
+ r.C_ = 17;
+ std::normal_distribution<double> nd(0, 1);
+ UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.5615566731, 0.01);
+ }
+
+ {
+ TRng<ui16> r;
+ r.C_ = 17;
+ std::normal_distribution<long double> nd(0, 1);
+ UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.430375088, 0.01);
+ }
+ }
+}