aboutsummaryrefslogtreecommitdiffstats
path: root/util/random/mersenne_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/random/mersenne_ut.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/random/mersenne_ut.cpp')
-rw-r--r--util/random/mersenne_ut.cpp144
1 files changed, 72 insertions, 72 deletions
diff --git a/util/random/mersenne_ut.cpp b/util/random/mersenne_ut.cpp
index a4b84efa3d..3f48d18831 100644
--- a/util/random/mersenne_ut.cpp
+++ b/util/random/mersenne_ut.cpp
@@ -1,82 +1,82 @@
-#include "mersenne.h"
-
+#include "mersenne.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/stream/output.h>
-
-#define UI32(x) x##ul
-
+
+#define UI32(x) x##ul
+
Y_UNIT_TEST_SUITE(TMersenneRndTest) {
- template <class T>
- inline void Test(const T* res, size_t len) {
- TMersenne<T> m;
-
- for (size_t i = 0; i < len; ++i) {
- UNIT_ASSERT_EQUAL(m.GenRand(), res[i]);
- }
- }
-
+ template <class T>
+ inline void Test(const T* res, size_t len) {
+ TMersenne<T> m;
+
+ for (size_t i = 0; i < len; ++i) {
+ UNIT_ASSERT_EQUAL(m.GenRand(), res[i]);
+ }
+ }
+
Y_UNIT_TEST(Test32) {
- const ui32 res[] = {
- UI32(2325592414),
- UI32(482149846),
- UI32(4177211283),
- UI32(3872387439),
- UI32(1663027210),
- UI32(2005191859),
- UI32(666881213),
- UI32(3289399202),
- UI32(2514534568),
- UI32(3882134983),
- };
-
+ const ui32 res[] = {
+ UI32(2325592414),
+ UI32(482149846),
+ UI32(4177211283),
+ UI32(3872387439),
+ UI32(1663027210),
+ UI32(2005191859),
+ UI32(666881213),
+ UI32(3289399202),
+ UI32(2514534568),
+ UI32(3882134983),
+ };
+
Test<ui32>(res, Y_ARRAY_SIZE(res));
- }
-
+ }
+
Y_UNIT_TEST(Test64) {
- const ui64 res[] = {
- ULL(13735441942630277712),
- ULL(10468394322237346228),
- ULL(5051557175812687784),
- ULL(8252857936377966838),
- ULL(4330799099585512958),
- ULL(327094098846779408),
- ULL(6143667654738189122),
- ULL(6387112078486713335),
- ULL(3862502196831460488),
- ULL(11231499428520958715),
- };
-
+ const ui64 res[] = {
+ ULL(13735441942630277712),
+ ULL(10468394322237346228),
+ ULL(5051557175812687784),
+ ULL(8252857936377966838),
+ ULL(4330799099585512958),
+ ULL(327094098846779408),
+ ULL(6143667654738189122),
+ ULL(6387112078486713335),
+ ULL(3862502196831460488),
+ ULL(11231499428520958715),
+ };
+
Test<ui64>(res, Y_ARRAY_SIZE(res));
- }
-
+ }
+
Y_UNIT_TEST(TestGenRand64) {
- TMersenne<ui32> rng;
-
- for (size_t i = 0; i < 100; ++i) {
- UNIT_ASSERT(rng.GenRand64() > ULL(12345678912));
- }
- }
-
+ TMersenne<ui32> rng;
+
+ for (size_t i = 0; i < 100; ++i) {
+ UNIT_ASSERT(rng.GenRand64() > ULL(12345678912));
+ }
+ }
+
Y_UNIT_TEST(TestCopy32) {
- TMersenne<ui32> r1(1);
- TMersenne<ui32> r2(2);
-
- UNIT_ASSERT_VALUES_UNEQUAL(r1.GenRand(), r2.GenRand());
-
- r2 = r1;
-
- UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand());
- }
-
+ TMersenne<ui32> r1(1);
+ TMersenne<ui32> r2(2);
+
+ UNIT_ASSERT_VALUES_UNEQUAL(r1.GenRand(), r2.GenRand());
+
+ r2 = r1;
+
+ UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand());
+ }
+
Y_UNIT_TEST(TestCopy64) {
- TMersenne<ui64> r1(1);
- TMersenne<ui64> r2(2);
-
- UNIT_ASSERT_VALUES_UNEQUAL(r1.GenRand(), r2.GenRand());
-
- r2 = r1;
-
- UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand());
- }
-}
+ TMersenne<ui64> r1(1);
+ TMersenne<ui64> r2(2);
+
+ UNIT_ASSERT_VALUES_UNEQUAL(r1.GenRand(), r2.GenRand());
+
+ r2 = r1;
+
+ UNIT_ASSERT_VALUES_EQUAL(r1.GenRand(), r2.GenRand());
+ }
+}